0

I'm writing a RIM BlackBerry client app. BlackBerry uses a simplified version of Java (no generics, no annotations, limited collections support, etc.; roughly a Java 1.3 dialect). My client will be speaking JSON to a server. We have a bunch of JAXB-generated POJOs, but they're heavily annotated, and they use various classes that aren't available on this platform (ArrayList, BigDecimal, XMLGregorianCalendar). We also have the XSD used by the JAXB-XJC compiler to generate those source files.

Being the lazy programmer that I am, I'd really rather not manually translate the existing source files to Java 1.3-compatible JSON-marshalling classes. I already tried JAXB 1.0.6 xjc. Unfortunately, it doesn't understand the XSD file well enough to emit proper classes.

Do you know of a tool that will take JAXB 2.0 XSD files and emit Java 1.3 classes? And do you know of a JSON marshalling library that works with old Java?

I think I am doomed because JSON arrived around 2006, and Java 5 was released in late 2004, meaning that people probably wouldn't be writing JSON-parsing code for old versions of Java.

However, it seems that there must be good JSON libraries for J2ME, which is why I'm holding out hope.

4

2 回答 2

1

对于第一部分,祝你好运,但我真的不认为你会找到比自己修改代码更好的解决方案。但是,有一个很好的 J2ME JSON 库,您可以在此处找到指向镜像的链接。

于 2010-05-18T21:53:29.557 回答
0

我最终使用apt(注释处理工具)来运行 1.5 源并发出新的 1.3 友好源。实际上结果证明是一个非常好的解决方案!

我还没有找到一种优雅的方式来进行实际的 JSON 编组,但是 apt 工具可能可以帮助编写与 JSON 库接口的死记硬背的代码,就像 Jonathan 指出的那样。

于 2010-05-19T18:34:56.993 回答