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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:52:06+00:00 2026-06-07T16:52:06+00:00

What I’m trying to do is create a JSONObject that contains an Array of

  • 0

What I’m trying to do is create a JSONObject that contains an Array of other JSONObjects that are organized by a String? for example i want to create a JSONObject that contains an array of objects that contain fixtures that are also organized by match date

to give you a visual reference of what i am trying to acheive

JSONObject (JSONArray("Object 10/10/12" {(fixtures content)(fixtures content)}")
                     ("Object 11/10/12" {(fixtures content)(fixtures content)}"))

heres what i have tried so far but just can’t get it to work

        String matchDate1 = null;
        JSONArray datesArray = null;
        JSONObject fixturesInfo = null;
        JSONArray fixturesInfoArray = null;
        String matchDateTemp = null;

        for(int f = 0; f < fixturesArray.length(); f++){

            JSONObject matchDateDict = fixturesArray.getJSONObject(f);
            matchDate1 = matchDateDict.getString("matchdate");
            JSONArray fixturesInfoDict = fixturesInfo.getJSONArray(matchDate1);

           if(fixturesInfoDict == null){
               tempArray = null;
           } else {
               tempArray = fixturesInfoDict;
           }

           if(matchDateTemp != matchDate1){
              fixturesInfoArray.put(matchDate1);
           }

          matchDateTemp = matchDate1;

          tempArray.put(fixturesArray.getJSONObject(f));
          fixturesInfo.put(matchDate1, tempArray);

        }




            Log.v("MyFix", "fixturesInfo = " + fixturesInfo);

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

heres the json feed

{
    "code": 200,
    "error": null,
    "data": {
        "fixtures": [{
            "kickoff": "15:00:00",
            "matchdate": "2012-07-14",
            "homescore": null,
            "awayscore": null,
            "attendance": null,
            "homepens": null,
            "awaypens": null,
            "division_id": "5059",
            "division": "Testing 1",
            "comp": "LGE",
            "location": null,
            "fixture_note": null,
            "hometeam_id": "64930",
            "hometeam": "Team 1",
            "awayteam_id": "64933",
            "awayteam": "Team 4"
        }, {
            "kickoff": "15:00:00",
            "matchdate": "2012-07-14",
            "homescore": null,
            "awayscore": null,
            "attendance": null,
            "homepens": null,
            "awaypens": null,
            "division_id": "5059",
            "division": "Testing 1",
            "comp": "LGE",
            "location": null,
            "fixture_note": null,
            "hometeam_id": "64935",
            "hometeam": "Team 6",
            "awayteam_id": "64937",
            "awayteam": "Team 8"
        }, {
            "kickoff": "15:00:00",
            "matchdate": "2012-07-28",
            "homescore": null,
            "awayscore": null,
            "attendance": null,
            "homepens": null,
            "awaypens": null,
            "division_id": "5059",
            "division": "Testing 1",
            "comp": "LGE",
            "location": null,
            "fixture_note": null,
            "hometeam_id": "64930",
            "hometeam": "Team 1",
            "awayteam_id": "64931",
            "awayteam": "Team 2"
        }, {
            "kickoff": "15:00:00",
            "matchdate": "2012-07-28",
            "homescore": null,
            "awayscore": null,
            "attendance": null,
            "homepens": null,
            "awaypens": null,
            "division_id": "5059",
            "division": "Testing 1",
            "comp": "LGE",
            "location": null,
            "fixture_note": null,
            "hometeam_id": "64930",
            "hometeam": "Team 1",
            "awayteam_id": "64931",
            "awayteam": "Team 2"
        }]
    }
}
  • 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-07T16:52:08+00:00Added an answer on June 7, 2026 at 4:52 pm

    From what you say, you seem like trying to build a JSONArray out of some JSONObjects. This might help:

    public void writeJSON() {
        JSONObject user = new JSONObject();
        JSONObject user2;
        user2 = new JSONObject();
        try {
            user.put("dish_id", "1");
            user.put("dish_custom", "2");
            user.put("quantity", "2");
            user.put("shared", "2");
    
            user2.put("dish_id", "2");
            user2.put("dish_custom", "2");
            user2.put("quantity", "4");
            user2.put("shared", "3");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
        JSONArray notebookUsers = new JSONArray();
        notebookUsers.put(user);
        notebookUsers.put(user2);
        System.out.println("the JSON ARRAY is"+notebookUsers);
    

    Here 2 json objects are added to 1 JSONArray.

    The output of the System.out.println will look something like this:

    the JSON ARRAY is[{"shared":"2","dish_custom":"2","dish_id":"1","quantity":"2"},{"shared":"3","dish_custom":"2","dish_id":"2","quantity":"4"}]
    

    And the string comparison you are using is not right.

    if(matchDateTemp != matchDate1)
    

    u cannot compare strings like that. u can use something like:

    if(!(matchDateTemp.equals(matchDate1)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.