• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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










 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic