1

In Java SE/EE, you can generate a Java model from an XML schema and then marshal and unmarshal Java to XML or JSON. The marshallers use reflection and annotations which are not available for most Java mobile APIs which have more or less a Java 1.4 compatibility level.

Is there any existing solution for Java-to-JSON binding on such restricted platforms that does not use platform specific APIs (e.g. Android)?

A possible approach might be an XJC plugin that suppresses annotations and adds marshal() and unmarshal() methods to each model class.

Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63
  • See my old question: http://stackoverflow.com/questions/9734921/is-there-a-need-in-jaxb-implementation-for-android – lexicore Sep 07 '14 at 18:53

2 Answers2

0

See also: Is there a need in JAXB implementation for Android?

I have not seen such solutions.

It is surely possible to workaround both annotations and reflection by generating the marshalling/unmarshalling code directly in schema-derived classes - just as you suggest. Actually JAXB 1 worked in this way in many senses. However I'm not sure if there's a pressing need for such technology.

ps. I've implemented a JAXB analog for JavaScript (compiler is based on XJC) so it would be definitely possible.

Community
  • 1
  • 1
lexicore
  • 42,748
  • 17
  • 132
  • 221
0

There is a solution named JSONx Framework, but it requires jdk1.8 at the least.

Seva Safris
  • 401
  • 4
  • 12