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

  • Home
  • SEARCH
  • 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 8633543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:30:34+00:00 2026-06-12T09:30:34+00:00

hi am facing some kind of issue with the code . Following is my

  • 0

hi am facing some kind of issue with the code . Following is my code to generate json data

for(int i=0; i < allEds.size(); i++){
                String edsText = allEds.get(i).getText().toString();                                           
               //spinner = allSpns.get(i);
               String spinSelected=allSpns.get(i).getSelectedItem().toString();                  
               try
                {
                   JSONObject json = new JSONObject();          
                   json.put("FieldName", edsText);
                   json.put("FieldType",spinSelected);
                   parent.accumulate("data", json);



                }
                catch (JSONException e)
                {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }                   

            }

It work fine and getting if i made more than one entry to json

correct out put
{"data":[{"FieldType":"Character","FieldName":"fffg"},{"FieldType":"Character","FieldName":"fg"]}

When only one entry as json it gives the following out

{"data":{"FieldType":"Character","FieldName":"ffg","Id":0}}

While parsing the second json am getting errors..Any thing wrong on my code?

code i used for parsing json

JSONObject jsonObj = new JSONObject(folderStructure);
        JSONArray data = jsonObj.getJSONArray("data");
         //ArrayList<HashMap<String, String>> folderList = new ArrayList<HashMap<String, String>>();
        for(int i=0; i<data.length(); i++)
        {

            //HashMap<String, String> map = new HashMap<String, String>();
             JSONObject obj=data.getJSONObject(i);
             String id = obj.getString("Id"); 
                String valueName = obj.getString("FieldName"); 
                String valueType = obj.getString("FieldType"); 
}
  • 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-12T09:30:35+00:00Added an answer on June 12, 2026 at 9:30 am
    JSONObject parent = new JSONObject();
    JSONArray jdata = new JSONArray();
    
        try{
             for(int i=0; i < allEds.size(); i++){
                 JSONObject childObj = new JSONObject();         
                 childObj .put("FieldName", allEds.get(i).getText().toString());
                 childObj .put("FieldType",allSpns.get(i).getSelectedItem().toString());
    
                 jdata .put(childObj).toString();
                }
              parent.put("data",jdata);
           }
           catch (JSONException e){
             // TODO Auto-generated catch block
             e.printStackTrace();
           }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Facing some issue in Talend Admin Console, the jobs that are running from IDE
I have developed some code, and I'm facing problem with error flagging of the
I have some confusion. Not really a bug or issue I am facing. I
Right now I'm facing some kind of strange problem with a Weblogic domain. When
I'm facing difficulty when creating some kind of a report in vfp. I created
I'm facing some kind of mystery : if( itemSelectionne->parentItem()->type() == NodeType) { ((GraphicsScene*) this->scene())->unselectAll();
I am facing some issues in loading a CSV file through SQL Loader. Here
I'm facing some problems with my silverlight application. My application looks like an image
I am facing some issues while serializing objects (I am using JBoss Drools, and
I'm facing some complexities when developing a medium-complex Android application. I'm searching for information

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.