-1

I am not able to parse the incoming Bundle request (JSON) to the Java data objcets. It seems that the parser does not recognize the "resourceType": "Bundle". Parser fails on if (json.has("feed")) statement of JsonParserBase. I have also tried using "resourceType": "feed" but no luck.

Java implementation does not gives a concrete parser whereas it is available for .NET version. My application is Java based and it is not able to recognize the incoming Bundle request. I am using org.hl7.fhir.instance.formats.JsonParser's parseGeneral() method.

Are there any third party parsers available or I am missing any thing?

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
Ashish
  • 421
  • 9
  • 22
  • One presumes you're doing this in some programming language? And using some sort of JSON parser and possibly one of those screwy setups that creates objects directly from the JSON? But we'll never know, will we, because you told us NOTHING! – Hot Licks Apr 10 '14 at 00:00
  • Sorry about that. Edited question by adding more details. – Ashish Apr 10 '14 at 00:44
  • There are over 2 dozen different parsers for JSON. Not familiar with the one you describe. But any parser should be able to parse legal JSON. The issues would be with add-ons to the basic parser that either attempted to enforce a "schema" or that attempted to create a Java object directly from the JSON, without intervening logic you write. It's impossible for us to know about these unless you describe them. – Hot Licks Apr 10 '14 at 00:52
  • Note that you should go to json.org and spend the 5-10 minutes it takes to learn the JSON syntax. And you should "capture" the JSON source you are using and run that through an "online JSON parser" to verify that it's valid JSON and has not been corrupted in transmission. Plus edit the problem parts of your JSON into your question. – Hot Licks Apr 10 '14 at 00:54
  • I have already defined the Parser (`org.hl7.fhir.instance.formats.JsonParser`) in my question which I am using. This question is specific to FHIR (Hl7) Standards. I have the data objects ready but the HL7 specific JSON parsor is not mapping it with the defined set. I Request you to please answer or provide comments only if you have worked in this technology and just do not answer for sake of answering. Obviously, I had a valid JSON string which I am trying to parse. This is not my first time with JSON. – Ashish Apr 10 '14 at 01:32

1 Answers1

2

This is a bug in the Java parser that I fixed a few hours before you asked the question. You can get the latest fixed parser from the FHIR gForge (see http://wiki.hl7.org/index.php?title=FHIR_Build_Process for access), and we are working on new releases (at http://hl7.org/fhir and through maven).

Not sure what this means: "Java implementation does not gives a concrete parser whereas it is available for .NET version". I think the Java parser is concrete. In this case, it was just wrong.

Grahame Grieve
  • 3,538
  • 3
  • 15
  • 17
  • Yes, I mean the same thing. I could not find something called "Bundle.java", where as I guess it is available in the .NET world. I have figured out how it will work. If I wrap my complete request inside `"feed"`, I am able to convert it to data object. This is what I have done. Please provide your inputs regarding the same. `ResourceOrFeed resourceorFeed = jsonParser.parseGeneral(new ByteArrayInputStream(jsonString.getBytes()));` Also, can you explain in brief what bug did you fixed? – Ashish Apr 10 '14 at 05:28
  • in the java reference implementation the class is called "AtomFeed" instead of Bundle - mainly because the class predated our decision to call the thing Bundle once we started using a JSON variant for it. What I changed in the parser is that it no longer looks for the "feed" object, it looks for resourceType : Bundle as the specification says – Grahame Grieve Apr 10 '14 at 06:05
  • Sounds great. Have requested for SVN account. Will checkout a latest release once account is activated. Is there any SVN server with anonymous checkout available? – Ashish Apr 10 '14 at 06:36