将JSON导入Eclipse项目 [英] Importing JSON into an Eclipse project

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

问题描述

我是一个有抱负的Java程序员,希望在项目中使用JSON。我正在遵循编程教程(从一本书),要求我通过使用以下行将JSON导入我的项目:

 导入com.google.appengine.repackaged.org.json.JSONArray; 

但是这产生了一个错误,所以我用这一行替换了它:

  import org.json.JSONArray; 

这也会产生(不同的)错误:


导入org.json无法解析


我认为问题是我不实际上我的Eclipse工作区中有JSON库。我该怎么做,所以我可以使用JSONArray?我发现JSON的网站,但不知道下载什么以及安装方式或位置:



http://json.org/java/

解决方案

下载来自此 URL 的ZIP文件,并解压缩以获取Jar。将JAR添加到您的构建路径。要检查此Jar中的可用类,请使用此 URL



将此Jar添加到构建路径右键单击项目>构建路径>配置构建路径>选择库选项卡>单击添加外部库>选择Jar文件下载



我希望这将解决您的问题


I'm an aspiring Java programmer looking to use JSON in a project. I was following a programming tutorial (from a book) which asked me to import JSON into my project by using the following line:

import com.google.appengine.repackaged.org.json.JSONArray; 

But this produced an error, so I replaced it with this line:

import org.json.JSONArray;

This also produces a (different) error:

The import org.json cannot be resolved

I think the problem is that I don't actually have the JSON library in my Eclipse workspace. How can I do this, so I can use the JSONArray? I found the website for JSON, but am not sure what to download or how or where to install it:

http://json.org/java/

解决方案

Download the ZIP file from this URL and extract it to get the Jar. Add the Jar to your build path. To check the available classes in this Jar use this URL.

To Add this Jar to your build path Right click the Project > Build Path > Configure build path> Select Libraries tab > Click Add External Libraries > Select the Jar file Download

I hope this will solve your problem

这篇关于将JSON导入Eclipse项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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