eclipse 从 Github 安装 Gson

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31829001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:46:43  来源:igfitidea点击:

Install Gson from Github

javaeclipsepackagegsonlibraries

提问by TAS

I'm just starting to learn Java and I need Gson for a new project that I'm working on.

我刚刚开始学习 Java,我需要 Gson 用于我正在从事的新项目。

I feel like I'm missing something with all the installation instructions that I find online--all of them refer to three jar files that I should be able to extract from a zip file. But when I look at Gson on github i can't find any .jar files!

我觉得我在网上找到的所有安装说明都遗漏了一些东西——所有这些都是指我应该能够从 zip 文件中提取的三个 jar 文件。但是当我在 github 上查看 Gson 时,我找不到任何 .jar 文件!

https://github.com/google/gson

https://github.com/google/gson

Once I find the jar files, I'm just supposed to include them in the buildpath for the project I'm working on right?

一旦找到 jar 文件,我就应该将它们包含在我正在处理的项目的构建路径中,对吗?

I'm working on this project using Eclipse.

我正在使用 Eclipse 处理这个项目。

Can someone help me with a very simple step-by-step explanation of how to start including these libraries for a complete noob to programming like me?

有人可以通过非常简单的分步说明来帮助我了解如何开始包含这些库,以便像我这样的完全菜鸟编程吗?

Also, once I include the .jar files in the buildpath for a project, can I just call the functions?

另外,一旦我在项目的构建路径中包含 .jar 文件,我可以只调用函数吗?

回答by Subodh Joshi

Simple put all jar files in your project lib folder Right Click on your Project->Properties-> Java Build Path->Librariesand you can download Gsonfrom here If you looking for some specific version please add in your question

简单地将所有 jar 文件放在您的项目 lib 文件夹中Right Click on your Project->Properties-> Java Build Path->Libraries,您可以从这里下载Gson如果您正在寻找某些特定版本,请添加您的问题

http://www.java2s.com/Code/Jar/g/Downloadgson222jar.htm

http://www.java2s.com/Code/Jar/g/Downloadgson222jar.htm

回答by Valamburi M

  1. Find out the latest version(2.3.1)by this time, from the MAVEN central repository.
  2. You can find the step by step procedures to add jars to your project from this step by step "How to Add JARs to Project Build Paths in Eclipse (Java)"?
  1. 到此为止,从 MAVEN 中央存储库中找出最新版本(2.3.1)
  2. 您可以从这一步“如何将 JAR 添加到 Eclipse (Java) 中的项目构建路径”中找到将 jar 添加到您的项目的分步过程?

回答by John smith

as you are using Gsonfor serializationand deSerializationof jsondata you have to include Gsonlib from here. on the other end, with Android Studioyou can include the following line to your gradle:

当您使用GsonforserializationdeSerializationofjson数据时,您必须Gson此处包含lib 。另一方面,Android Studio您可以将以下行包含在您的 gradle 中:

 compile 'com.google.code.gson:gson:2.3.1'

Then you will be able to call Gsonin-builds method and constructor like:

然后您将能够调用Gson内置方法和构造函数,例如:

1 - Gson gson = new Gson();

1 - Gson gson = new Gson();

2 - gson.fromJson();

2 - gson.fromJson();

3 - gson.toJson();

3 - gson.toJson();

enjoy your code :)-

享受你的代码:)-