Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7401129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:23:11+00:00 2026-05-29T04:23:11+00:00

Hi I am trying to use Json Simple to select the cheese entry, however

  • 0

Hi I am trying to use Json Simple to select the “cheese” entry, however I seem to be returning “null” when I try to select it. Would be excellent to have some advice on how to do this?`

Here is the Json sample:

String s="[\"coins\",{\"wallet\":{\"shoppinglist\":{\"cheese\":{\"ingrediants\":[\"milk\",{\"preservative1\":\"wax\"}]}}}}]";

and here is the code:

      System.out.println(s);
        System.out.println("=======decode=======");

      Object obj=JSONValue.parse(s);
      JSONArray array=(JSONArray)obj;
      System.out.println("======the 2nd element of array======");
      System.out.println(array.get(1));
      System.out.println();
      System.out.println("======the 1st element of array======");
      System.out.println(array.get(0));
      System.out.println();



      JSONObject obj2=(JSONObject)array.get(1);
      System.out.println("======field \"1\"==========");
      System.out.println(obj2.get("wallet"));  


      JSONObject obj3=(JSONObject) obj2.get("shoppinglist");
      System.out.println("======field \"2\"==========");
      System.out.println(obj3);  //This figure is returning null when I would like it to return the json object shopping list

It currently outputs:

     ["coins",{"wallet":{"shoppinglist":{"cheese":{"ingrediants":["milk",{"preservative1":"wax"}]}}}}]
    =======decode=======
    ======the 2nd element of array======
    {"wallet":{"shoppinglist":{"cheese":{"ingrediants":["milk",{"preservative1":"wax"}]}}}}

    ======the 1st element of array======
    coins

    ======field "1"==========
    {"shoppinglist":{"cheese":{"ingrediants":["milk",{"preservative1":"wax"}]}}}
    ======field "2"==========
    null
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:23:13+00:00Added an answer on May 29, 2026 at 4:23 am

    You’re skipping one step in the nesting. obj2 has the property “wallet”. “shoppinglist” is one level deeper.

    To get the intended result, use this:

    JSONObject wallet       = (JSONObject) obj2.get("wallet");
    JSONObject shoppinglist = (JSONObject) wallet.get("shoppinglist");
    System.out.println(shoppinglist);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn how to use JSON and writing a simple program
I'm trying to use Json.NET to serialize and deserialze a tree structure for jsTree.
I'm trying to use json for my web page's globalization options.. id like to
I am trying to use JSON to populate a div, so I basically run
i'm trying to use json_decode to combine a few json objects and then re-encode
I am trying to use amcharts and I want to use JSON to format
I'm trying to use Request.JSON in mooTools to bring in an object from a
I'm trying to return use a JSON object with handlebars. Making a small todo
I am trying to use the NETFx Json.NET MediaTypeFormatter nuget package to swap out
Trying to use Jbuilder to create some JSON views for my app, but the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.