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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:33:01+00:00 2026-06-05T04:33:01+00:00

Ineed to post data in JSON format as shown below And the size of

  • 0

Ineed to post data in JSON format as shown below And the size of the array is not
constant. it depends on the user.

  {
  "info": [
    {
      "Name": "foo1",
      "Number": 123
    },
    {
      "Name": "foo2",
      "Number": 124
    },
    {
      "Name": "foo2",
      "Number": 125
    }
  ]
}

I tried to create in the following way

JSONObject parent = new JSONObject();
JSONArray jArray = new JSONArray();
JSONObject childObj = new JSONObject();


childObj.put("Name", etName.getText()).toString();
childObj.put("Number", etNumber.getText()).toString();

jArray.put(childObj);

parent.put("info",jArray);

but i’m unable to get it and I also tried in this way like example 6.1 but there is no method like add for JSONArray. So how can post my data. Please help me.
Thanks.

  • 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-06-05T04:33:04+00:00Added an answer on June 5, 2026 at 4:33 am

    I’m not sure exactly what your question is but I’d typically do something like this to create the JSON string that you are looking for (the example below is using the org.json reference implementation from http://www.json.org/java/index.html):

    JSONObject parent = new JSONObject();
    JSONArray infoArray = new JSONArray();
    
    
    for(int i = 0; i < SOMEARRAY.length; i++)
    {
        JSONObject childObj = new JSONObject();
        childObj.put("Name", etName.getText());
        childObj.put("Number", etNumber.getText());
        infoArray.put(childObj);
    }
    
    parent.put("info", infoArray);
    
    String encodedJsonString = parent.toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to cause a user's browser to post data using PHP to another
From a webpage, I need to send JSON data using POST method to a
In my application, I do a jquery post which gets an array of json
Phil Haack has an excellent blog post on how to use JSON, data binding,
I am getting some data in JSON format via jQuery and then I need
I've got a form and I need to post data to the server every
I need to send a post request when the user leaves the page in
I'm calling an asp.net webservice with JQuery and ajax, transfering data with json. I'm
Hi, i have been having some problems using JSON data in flash builder lately
I have a lot of JSON data I need to pass to a request:

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.