2013-03-19 7 views
3

J'utilise JCAPS 5.1.3 et je n'ai que Java 1.4 et j'ai besoin de gérer les données Json. Malheureusement, toutes les bibliothèques que j'ai trouvées utilisent Java 1.5 et supérieur. I just found lots of new implementations in this thread here, but which one works with 1.4.Bibliothèque json pour java 1.4

Existe-t-il une version stable et simple à utiliser avec Java 1.4?

+2

http://www.json.org/java/ – nattyddubbs

+3

Je recommande vraiment vous mettre à jour vers une nouvelle version Java. Un grand avantage de Java est la rétrocompatibilité. – Eich

Répondre

0

Xstream 1.2.2 prend en charge Java 1.4. C'est la seule bibliothèque que j'ai trouvée qui supporte Java 1.4. Il a certainement ses verrues bien.

0

Vous pouvez utiliser my json library. Il prend en charge le marshalling et unmarshalling aux classes (avec quelques restrictions) et l'analyse.

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); 
+0

Wow, vous avez vraiment déterré ce post d'il y a plus de 2 ans –