Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Im trying to parse the following JSON from a web service callout, however im getting the above error on this line:

while(parser.nextToken() != null)

Is it to do with the '\' in the json?? if so how do i deal with it? Appreciate any suggestions?

{   "place_id":"12037085",
"licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright",
"osm_type":"node",
"osm_id":"1112205402",
"boundingbox":[51.4660524,51.4661524,-0.1537554,-0.1536554],
"lat":"51.4661024",
"lon":"-0.1537054",
"display_name":"Nany Lamb Indonesian, Woodmere Close, Clapham Junction, London Borough of Wandsworth, London, Greater London, England, SW11, United Kingdom, European Union",
"class":"amenity",
"type":"restaurant",
"importance":0.401,
"icon":"http:\/\/open.mapquestapi.com\/nominatim\/v1\/images\/mapicons\/food_restaurant.p.20.png",
"address":
    {
    "restaurant":"Nany Lamb Indonesian",
    "road":"Woodmere Close",
    "suburb":"Clapham Junction",
    "city":"London Borough of Wandsworth",
    "county":"London",
    "state_district":"Greater London",
    "state":"England","postcode":"SW11",
    "country":"United Kingdom",
    "country_code":"gb",
    "continent":"European Union"
    }
}
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Your parsing this in Apex, correct?

I was able to feed your sample JSON into JSON2Apex and generate strongly typed Apex classes to parse it. The one issue here was the class member as it conflicted with a reserved Apex keyword. See How do you deserialize json properties that are reserved words in apex?

Debugging the license member gave:

Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright

And icon:

http://open.mapquestapi.com/nominatim/v1/images/mapicons/food_restaurant.p.20.png

So it seemed to parse fine with the exception of the reserved keyword.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.