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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:22:22+00:00 2026-05-27T16:22:22+00:00

EDIT: I actually found the answer. I can’t close the question as I am

  • 0

EDIT: I actually found the answer. I can’t close the question as I am new. I was able to use Array.getString(i) to return the string value needed. Thanks for all the help.

I have JSON like this:

{
  "List": [
    "example1",
    "example2",
    "example3",
    "example4"
  ]
}

And I am trying to get the string value of those objects without using a key. How can I do that? The getString() for jsonObject require a key and I don’t have one.

  • 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-27T16:22:23+00:00Added an answer on May 27, 2026 at 4:22 pm

    I assume that you have a file :/home/user/file_001.json

    the file contains this : `

    {"age":34,"name":"myName","messages":["msg 1","msg 2","msg 3"]}
    

    Now let’s write a program that reads the file : /home/user/file_001.json
    and converts its content to a java JSONObject.

    package org.xml.json;
    
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Iterator;
    
    import org.json.simple.JSONArray;
    import org.json.simple.JSONObject;
    import org.json.simple.parser.JSONParser;
    import org.json.simple.parser.ParseException;
    
    
        public class JsonSimpleRead
        {
            @SuppressWarnings("unchecked")
            public static void main(String[] args)
            {
                JSONParser parser = new JSONParser();
                try
                {
                    Object obj = parser.parse(new FileReader("/home/user/file_001.json"));
                    JSONObject jsonObject = (JSONObject) obj;
                    String name = (String) jsonObject.get("name");
                    System.out.println(name);
    
                    long age = (Long) jsonObject.get("age");
                    System.out.println(age);
    
                    JSONArray msg = (JSONArray) jsonObject.get("messages");
                    Iterator<String> iterator = msg.iterator();
                    while (iterator.hasNext())
                    {
                        System.out.println(iterator.next());
                    }
                }
                catch (FileNotFoundException e)
                {
                    e.printStackTrace();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
                catch (ParseException e)
                {
                    e.printStackTrace();
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I apologize everybody. I used the term jagged array when I actually meant
I'm not sure what this practice is actually called, so perhaps someone can edit
Edit: From another question I provided an answer that has links to a lot
EDIT: I figured out the answer to the original YUI3 question I posted here,
NOTE: I finally found an exact duplicate question and good answer at: Get script
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
Edit--@Uri correctly pointed out that this was an abuse of annotations; trying to actually
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question is more about language engineering than C++ itself. I used C++
I am really new to Haskell (Actually I saw Real World Haskell from O'Reilly

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.