【问题标题】:json library for java 1.4java 1.4的json库
【发布时间】:2013-03-19 13:46:28
【问题描述】:

我使用的是 JCAPS 5.1.3,只有 Java 1.4,需要处理 Json 数据。不幸的是,我发现的所有库都使用 Java 1.5 及更高版本。 I just found lots of new implementations in this thread here, but which one works with 1.4.

是否有稳定且简单的版本可用于 Java 1.4?

【问题讨论】:

  • 我真的建议您更新到更新的 Java 版本。 Java 的一大优势是向后兼容。

标签: java json java1.4


【解决方案1】:

Xstream 1.2.2 支持 Java 1.4。这是我发现的唯一支持 Java 1.4 的库。不过,它肯定有它的缺点。

【讨论】:

    【解决方案2】:

    另一种方法是使用 Retroweaver 使 jar 与 Java 1.4 兼容:

    http://retroweaver.sourceforge.net

    【讨论】:

      【解决方案3】:

      您可以使用my json library。它支持编组和解组到类(有一些限制)和解析。

      编组:

      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();
      

      解组:

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

      【讨论】:

      • 哇,你真的把这篇文章从 2 年前挖出来了
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-09
      • 1970-01-01
      • 2014-09-12
      • 1970-01-01
      相关资源
      最近更新 更多