0

Is there any example to show how a json schema can be written to include multiple independent objects in one file?

If its possible, is there any java library that can convert all of them to individual pojos and vice versa?

l a s
  • 3,836
  • 10
  • 42
  • 61

1 Answers1

1

JSON requires you to always have either one array or one object as root element. If that is not the case, it is not valid JSON.

That being said, why don't you just wrap your multiple indidpendent objects in one root object? Doing this, you will be able to use any functional JSON marshaller.

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
  • You probably mean "wrap your...objects in one root array"? – Steve Bennett May 25 '15 at 01:18
  • @SteveBennet Why is that? From a JSON perspective it shouldn't matter, but wrapping it in an object would make the unmarshalling in java a bit more straightforward... Or am I missing something here? – TimoStaudinger May 25 '15 at 01:27
  • Oh I just figured if you have several "independent objects" you don't necessarily have keys to assign to them, which makes smoodging them into an object more complicated. – Steve Bennett May 25 '15 at 13:45