rosi
rosi

Reputation: 41

json library for java 1.4

I'm using JCAPS 5.1.3 and only have Java 1.4 and need to handle with Json data. Unfortunately all libraries I've found use Java 1.5 and above. I just found lots of new implementations in this thread here, but which one works with 1.4.

Is there a stable and simple version to use with Java 1.4?

Upvotes: 4

Views: 6328

Answers (3)

drt
drt

Reputation: 888

Xstream 1.2.2 supports Java 1.4. It's the only library I've found that supports Java 1.4. It definitely has its warts though.

Upvotes: 2

Mariano LEANCE
Mariano LEANCE

Reputation: 1106

You can use my json library. It supports marshalling and unmarshalling to classes (with some restrictions) and parsing.

Marshalling:

Knight knight = new Knight();

knight.name = "Lancelot";
knight.weapon = new Weapon();
knight.weapon.metal = "true silver";
knight.weapon.name = "piercer";
knight.rank = 2;
knight.titles = new String[] { "noble", "round table member" };

Land goldshire = new Land();
goldshire.name = "GoldShire";
goldshire.surface = 45532.3;
Land direwood = new Land();
direwood.name = "Direwood";
direwood.surface = 472;
knight.lands = new Land[] { goldshire, direwood };

System.out.println("Test 1 : marshall simple class:");
String generated = JsonFactory.marshal(knight).toString();

Unmarshalling:

Knight knight = (Knight) JsonFactory.unmarshal(new FileTools().readFile("UnmarshallingTest1.json"), Knight.class);

Upvotes: 1

Emmanuel Bourg
Emmanuel Bourg

Reputation: 10978

An alternative is to use Retroweaver to make the jar compatible with Java 1.4:

http://retroweaver.sourceforge.net

Upvotes: 1

Related Questions