Json Parsing error
See original GitHub issueI need to parse this JSON with as minimum code as possible. How can i achieve this?
SAMPLE JSON -
{
"count": 30,
"recipes": [
{
"publisher": "Closet Cooking",
"f2f_url": "http:\/\/food2fork.com\/view\/35382",
"title": "Jalapeno Popper Grilled Cheese Sandwich",
"source_url": "http:\/\/www.closetcooking.com\/2011\/04\/jalapeno-popper-grilled-cheese-sandwich.html",
"recipe_id": "35382",
"image_url": "http:\/\/static.food2fork.com\/Jalapeno2BPopper2BGrilled2BCheese2BSandwich2B12B500fd186186.jpg",
"social_rank": 100,
"publisher_url": "http:\/\/closetcooking.com"
},
{
"publisher": "The Pioneer Woman",
"f2f_url": "http:\/\/food2fork.com\/view\/47024",
"title": "Perfect Iced Coffee",
"source_url": "http:\/\/thepioneerwoman.com\/cooking\/2011\/06\/perfect-iced-coffee\/",
"recipe_id": "47024",
"image_url": "http:\/\/static.food2fork.com\/icedcoffee5766.jpg",
"social_rank": 100,
"publisher_url": "http:\/\/thepioneerwoman.com"
},
]
}
I tried this -
AndroidNetworking.get(Constants.RECIPE_DUMMY_ENDPOINT)
.setPriority(Priority.HIGH)
.build()
.getAsObjectList(Recipe.class, new ParsedRequestListener<List<Recipe>>() {
@Override
public void onResponse(List<Recipe> response) {
Log.i(TAG, "onResponse: "+response.size());
Log.i(TAG, "onResponse: "+response.get(0).toString());
}
@Override
public void onError(ANError anError) {
Log.e(TAG, "onError: "+anError.getErrorDetail() );
}
});
It gives parsing error - E/MainActivity: onError: parseError
The Recipe class contains all the getters,setters and parameterised constructor for each of the JSON objects inside the JSON array “responses”.
Where am I going wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >How to handle invalid JSON parse error properly.
The most common way to handle JSON parse error is using try-catch block. If the JSON string is valid, it will return a...
Read more >SyntaxError: JSON.parse: bad parsing Breaking Your Code ...
In JavaScript, when passing JSON to the JSON.parse() method, the method expects properly formatted JSON as the first argument. When it detects ...
Read more >What Is JSON and How to Handle an “Unexpected Token” Error
In this article you will learn what JSON is and how you can deal with errors occurring when parsing JSON data, such as...
Read more >SyntaxError: JSON.parse: bad parsing - DZone
SyntaxError is an inherited object of the main error object The main reason behind the error is usually a mistake in the JSON...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great. That works. Thanks alot! Could you please add this small detail in the Readme? Would help everyone.
Oh okay i got it. Will try that just now