在java中解析RecipeUppy中的json

在java中解析RecipeUppy中的json,java,arrays,json,Java,Arrays,Json,我正在尝试制作一个java命令行工具,允许您输入任何食物的名称,它将为您提供有关它的更多信息,例如配料和图像链接。为了获得数据,我使用了recipe puppy API。我已经设法将来自recipe puppy的json转换成一个字符串,我称之为mFoodJson 现在,我希望能够获取字符串的json内容,并能够以类似数组的形式访问它,因此,例如,我可以在recipe puppy中获得搜索比萨饼的第一个结果,并返回类似以下内容的配料(假设mFoodJson包含recipe puppy的json)

我正在尝试制作一个java命令行工具,允许您输入任何食物的名称,它将为您提供有关它的更多信息,例如配料和图像链接。为了获得数据,我使用了recipe puppy API。我已经设法将来自recipe puppy的json转换成一个字符串,我称之为mFoodJson

现在,我希望能够获取字符串的json内容,并能够以类似数组的形式访问它,因此,例如,我可以在recipe puppy中获得搜索比萨饼的第一个结果,并返回类似以下内容的配料(假设mFoodJson包含recipe puppy的json)

recipe puppy从其API返回的json示例如下(假设搜索的食物是“pizza”):


不要重新发明轮子。有很多json解析器,比如Jackson、Gson或LoganSquare。谷歌为他们服务

String[] mFoodArray = mFoodJson.toArray();
System.out.println("Ingredients in " + mFoodQuery + ": " + mFoodArray[1].ingredients;
{
    "title":"Recipe Puppy",
    "version":0.1,
    "href":"http:\/\/www.recipepuppy.com\/",
    "results": 
    [
        {
            "title":"BBQ Chicken Pizza",
            "href":"http:\/\/www.recipezaar.com\/BBQ-Chicken-Pizza-144689",
            "ingredients":  "chicken, brown sugar, cayenne, garlic salt, green pepper, honey, italian cheese blend, salad dressing, margarine, molasses, onions, barbecue sauce, black pepper, prepared pizza crust, provolone cheese, ranch dressing, salt",
            "thumbnail":""
        },
        {
            "title":"Basic Chicago-style Pizza Recipe",
            "href":"http:\/\/www.grouprecipes.com\/65487\/basic-chicago-style-pizza.html",
            "ingredients":  "pizza, vegetable oil,cornmeal, water, flour, sausage, provolone cheese, olive oil, tomato, yeast, pepperoni, salt, salt, sugar, basil, oregano",
            "thumbnail":""
        },
        {
            "title":"BBQ'd Cheeseburger Pizza",
            "href":"http:\/\/www.recipezaar.com\/BBQd-Cheeseburger-Pizza-299376",
            "ingredients":  "barbecue sauce, cheddar cheese, onions, tomato, dill pickle, dill relish, parsley, french dressing, garlic powder, ground beef, lettuce, mayonnaise, mozzarella cheese, pizza dough, mustard",
            "thumbnail":"http:\/\/img.recipepuppy.com\/152332.jpg"
        }
    ]
}