一,工程pom文件中新增依赖,参考http://mvnrepository.com/artifact/org.json/json/20160212

    <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20160212</version>
    </dependency>

二、用到的部分代码,用Json 字符串生成json对象,再从中获取需要的字段

        /* 解析消息 */
        String clientMsg = tuple.getStringByField("clientInfo");
        
        /* covert string to json object */
        JSONObject clientMsgObject = new JSONObject(clientMsg); 
        
        String acSNStr = clientMsgObject.getString("acSN");
        String clientMacStr = clientMsgObject.getString("clientMAC");
        String onLineTimeStr = clientMsgObject.getString("onLineTime");

三、lib源码

https://github.com/stleary/JSON-java

四、javadoc

https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.json%22%20AND%20a%3A%22json%22

 

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-10-22
  • 2021-07-23
  • 2022-12-23
  • 2022-03-04
  • 2021-05-26
猜你喜欢
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-11-01
  • 2021-12-30
相关资源
相似解决方案