用Java解码JSON [英] Decode JSON with Java

查看:104
本文介绍了用Java解码JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Java解码JSON数据.我在以下链接中找到了一个图书馆: http://code.google.com/p/json-simple/wiki/DecodingExamples

I am trying to decode JSON data with Java. I found a library at the following link: http://code.google.com/p/json-simple/wiki/DecodingExamples

我在eclipse项目的构建路径中包含了.jar文件,该文件在"Referenced Libraries"下添加了该库.但是,当我尝试使用上面链接中第一个示例所示的库时,找不到类型.

I have included the .jar file in the build path in my eclipse project, which added the library under "Referenced Libraries". But when I try to use the library as shown in the first example in the link above, the type is not found.

String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
Object obj=JSONValue.parse(s);
// Error: JSONValue cannot be resolved

我知道这个问题可能有点天真,但是有人可以指出我错了什么步骤吗?

I know this question may be a bit naive, but can someone point out what step I am doing wrong?

到目前为止的进口清单是:

The list of imports so far are:

import java.io.DataInputStream;
import java.io.DataOutputStream;    
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import org.json.JSONException;
import org.json.JSONStringer;

谢谢.

推荐答案

我认为您已经下载了json-simple-1.1-bundle.jar,相反,您应该下载第四个:json_simple-1.1.jar

I think you have downloaded json-simple-1.1-bundle.jar, instead, you should download the fourth one:json_simple-1.1.jar

这篇关于用Java解码JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆