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 3628346
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:00:19+00:00 2026-05-19T00:00:19+00:00

Please advice why I’m getting an exception on trying to create a JSONArray instance?

  • 0

Please advice why I’m getting an exception on trying to create a JSONArray instance?

String task = "{'menu': { 'id': 'file', 'value': 'File', 'popup': { 'menuitem': [ {'value': 'New', 'onclick': 'CreateNewDoc()'}, {'value': 'Open', 'onclick': 'OpenDoc()'}, {'value': 'Close', 'onclick': 'CloseDoc()'}] }}}";
        try { 
            JSONObject tmp = new JSONObject(task);
            js = tmp.getJSONArray("menuitem"); // exception fires here
        } catch(JSONException e) {
            e.printStackTrace();
        }

Getting an exception

01-03 16:12:17.926: WARN/System.err(5999): org.json.JSONException: No value for menuitem
  • 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-19T00:00:19+00:00Added an answer on May 19, 2026 at 12:00 am

    ‘menuitem’ is not a child of tmp. Try this:

    js = tmp.getJSONObject("menu").getJSONObject("popup").getJSONArray("menuitem");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem using deploy:deploy-file with snapshots I'd like some advice on please.
Please advice how can I render the preview of the existing PDF file to
could you please advice how to track progress of file upload to HTTP Server?
Am trying to pass the selected check box value to the control function. Please
Please advice, how to find selected value of a html select on its change.
could you please advice how to verify in python if provided string correspond to
int i=99; string s=i.ToString(D4); //s==0099 Please advice on efficient implementation of preceding zeroes of
Please advice on where can I find the lib in order to use the
Please advice how can I scroll a .NET TreeView Control programmatically. It doesn't implemented
Please advice whether is it correct method to change the urlconf and templatedir variables

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.