Getting the error while extracting JSON data using Await.result() with an infinite Duration

Recently, while working with the Scala-Play framework, I encountered an error when trying to fetch data from external websites. The line of code in question is

Await.result(xxx, Duration.Inf).json
, which resulted in a
JsonParseException: Unexpected character ('<' (code 60))
. Here's a snippet of my code:

var list:List[String]  = List();
var Url = "http://www.xxxxxx"
val Response = ws.url(Url).get()
val data = Await.result(Response, Duration.Inf).json

Any help or insights on how to resolve this issue would be greatly appreciated.

In terms of HTML Scraping, I am using the following libraries:

import net.ruippeixotog.scalascraper.browser.JsoupBrowser
import net.ruippeixotog.scalascraper.dsl.DSL._
import net.ruippeixotog.scalascraper.dsl.DSL.Extract._
import net.ruippeixotog.scalascraper.dsl.DSL.Parse._

import play.api.libs.ws.WSClient
import play.api.libs.ws.WSResponse

Answer №1

To determine if the response is valid JSON, try accessing the URL with a standard web browser. The error message indicates that the data returned from Await.result(Response, Duration.Inf) does not seem to be in a proper JSON format.

Answer №2

Feedback is not in a valid json format. Ensure that the URL is providing correct json data when using GET

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble converting JSON object to regular object?

I'm trying to change a JSON object into a regular object by using this method... var slaobj = eval('('+s+')'); However, it doesn't appear to be working correctly (the `.length' is returning as undefined). What m ...

What could be causing the select2 to not display the most up-to-date information in the control?

I have implemented a progressive search feature but it seems that the data returned is not populating the control properly. $("#selUser").select2({ ajax: { url: "/M01EngineeringData/GetFunctionalLocations", ty ...

Issues with decoding JSON data in PHP

Struggling to assign a JSON Object to a PHP Variable? When attempting to use var_dump, it's showing NULL. Here is the PHP code: <?php $json = utf8_encode(file_get_contents('http://socialclub.rockstargames.com/ajax/stat/1/profile_body/sta1/ ...

What is the method to determine the overall size of a webpage using the Google PageSpeed API?

"analytics": { "cssResponseBytes": "333 kB", "htmlResponseBytes": "269 kB", "imageResponseBytes": "3.35 MB", "javascriptResponseBytes": "2.29 MB", "numberCssResources": 2, "numberHosts": 80, "numberJsResources": 72, "numberR ...

Gathering data from distant servers through powershell

I need to retrieve drive information from a collection of Windows servers running between 2008 and 2016 using PowerShell. I have successfully written code to fetch the information locally, but I am struggling to do it remotely or from a text file containin ...

Determine the presence of a JSON object within a file using JavaScript

Currently, I am developing a mobile app using react-native and have been facing challenges implementing error checking. To store data retrieved from an API in JSON format, I am employing redux along with thunk. At times, the search results yield a JSON res ...

Parsing JSON in React resulted in an undefined object

It's worth mentioning that I am not a React expert and am simply trying my best to learn. If there are any obvious errors, please do point them out. I have been attempting to convert a JSON file into an object so that I can easily parse its contents ...

Having trouble extracting JSON data from an API in a Flutter application

My goal is to retrieve and parse JSON data from a REST API in node.js using express and MongoDB, and then present it as userdata. However, no matter what I attempt, I am unable to successfully parse the data. It either throws an exception like "Unhandled E ...

jQuery GetJson fails to execute success function

I'm trying to use this code for an Ajax request to a JSON file: let formData = $("#myform").serialize(); $.getJSON("/files/data.json?" + formData, function(response){ alert(response); } ); However, there are no errors and the alert is n ...

Showing XML image and text in Gridview sourced from JSON Data

I am encountering an issue while attempting to present both image and text data in a grid view with a 2 by 2 layout. I have successfully retrieved the data from XML using JSON. Below is my code snippet where I am encountering the problem, specifically at t ...

Encountered an issue when parsing JSON in Spring Boot: Unable to deserialize the

I'm encountering issues when trying to submit the form. Despite making changes in RoominfoController to accommodate arrays, the problem persists. Cannot deserialize value of type `com.example.pgfinder.models.RoomInfo` from Array value (token `JsonToke ...

Implement a guideline in Circe that requires at least one of two fields to be present

In my current project, I am working on a Circe parser that has a schema requirement where at least one of two fields must be set. This specific scenario is posing a challenge as there doesn't seem to be an easy way to achieve this using the Circe API. ...

JavaScript JSON function failing to show

I apologize for my limited knowledge on this matter... We are currently facing an issue with our website's pricing page. The dynamic calculator, which should display the price based on user input of size width and quantity, is not functioning as expe ...

Having trouble locating the file in c:? Android studio appears to be missing the obvious file location

Whenever I run this piece of code, I keep getting an error message saying "File not found" in the exception. It's puzzling because the file I'm searching for is right there at the root of my C drive. @Override protected void onCreate(Bundle save ...

Creating an if-else statement in PHP based on a JSON response - what's the best way to

I have made a JSON request that checks if my PC has a proxy set up. If it does, it shows "Yes", otherwise it shows "No". Now, I would like to publish two statements: If the status is "Yes": I want to display "You are protected" in green. If the status ...

Angular controller is failing to receive the dynamic JSON response from the RestAPI

Currently, I am working with JSON data retrieved from a REST API. I have successfully set up an alert that displays the JSON results within an $http.get function. Using a sample URL that contains test JSON data works perfectly fine and I receive the alert ...

Exploring Angular 2's ngFor Directive with JSON Data

Recently diving into Angular2, I've been trying to extract data from a JSON file. While I have successfully retrieved the file using a REST client, stored it in a local variable within a component, and accessed certain properties of that variable, I&a ...

Save a JSON-formatted string as a JSON file

I have a string in JSON format that looks like this: arbre={"name":"flare","children":[{"name":"Algèbre","children":[{"name":"Nombres Fractionnels","children":[{"name":"Addition fractionnelle","size":8.333333333333334}, {"name":"Division fractio ...

Retrieval of each single row from a PHP-generated JSON dataset

This is quite challenging, especially for me. My goal here is to use Javascript to extract each value of every row in this JSON data: {"id":2,"url":"image.png","x":19,"y":10,"user_id":20} {"id":3,"url":"image.png","x":19,"y":10,"user_id":20} {"id":4,"url" ...

The concept of undefined does not hold any tangible form

TypeError: undefined is not an object (evaluating 'this.props.data.map') appContent: displayData(){ let info = this.props.data.map(function(dataItem, index) { return ( <Card> <CardItem> <Body ...