• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need assistance with JSONJAXBContext ("...Content is not allowed in prolog")  RSS feed

 
laura mccord
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am receiving this error:

javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: Content is not allowed in prolog.]

I was able to get my project working using JAXBContext with an xml document. Now, I am revising my project to send a request to a service that responds with JSON instead, but it has been difficult and I can't get past the error above. The 3rd party json file looks like this:



This is how I am trying to unmarshal the response:




Here is the Persons class




Here is my Person class:




Thanks










 
Hikari Shidou
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol it's getting common ppl develop WebServices using JSON as format, and provide examples as definitions. Then consumers have to guess based on these examples and are unable to parse it.


is correctly forbed by your Person class.

But your Persons class has only the ROWS property and is missing SUCCESS and RESULTS. Also, it's better to use array instead of List.

After you have a proper collection of classes that parse that JSON, I suggest to create new ones to convert these ugly names into proper camelCase, then you can also ignore these 2 useless properties.

It's fun how he adds metadata info after the blob of data :p
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!