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

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

问题描述

我是一名有抱负的 Java 程序员,希望在项目中使用 JSON.我正在学习编程教程(来自一本书),该教程要求我使用以下行将 JSON 导入到我的项目中:

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:

无法解析导入的org.json

The import org.json cannot be resolved

我认为问题在于我的 Eclipse 工作区中实际上没有 JSON 库.我该怎么做才能使用 JSONArray?我找到了 JSON 的网站,但不确定要下载什么,或者如何或在哪里安装它:

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/

推荐答案

从此 URL 并将其解压缩以获取 Jar.将 Jar 添加到您的构建路径.要检查此 Jar 中的可用类,请使用此 URL.

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.

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

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

希望这能解决你的问题

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

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