小编Sho*_*kew的帖子

com.google.gson 包不存在

我正在使用以下程序:具体是 Tomcat 8、VirtualBox 虚拟机和 Gson 2.3.1

我正在尝试在 Gson 中测试一种方法,该方法允许您将 Java 对象编组/解组为 JSON 格式。

这是我使用它的代码(为了使其正确编译,两个java代码类需要同时编译......:

最重要的是我用于测试 JSON 转换方法的代码:

package com.cs330;
import com.google.gson.Gson;

    public class IngredientProto 
    {
        public static void main (String[] args)
        {
         Ingredient neo = new Ingredient(6, "cheddar cheese", "cheese");

         System.out.println("Object confirmed: " + neo.toString());

         //New GSON object for marshalling...
         Gson neoIngredient = new Gson();

         //Use said object to create the JSON formatted String for this Ingredient (Object).
         String jsonThis = neoIngredient.toJson(neo);

         //Printing out the new object (Ingredient)...
         System.out.println ("Object …
Run Code Online (Sandbox Code Playgroud)

java json gson

11
推荐指数
2
解决办法
5万
查看次数

标签 统计

gson ×1

java ×1

json ×1