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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:43:45+00:00 2026-05-13T11:43:45+00:00

Is there any way to have nested objects in JSON so I don’t have

  • 0

Is there any way to have nested objects in JSON so I don’t have to make arrays out of everything? For my object to be parsed without error I seem to need a structure like this:

{"data":[{"stuff":[
    {"onetype":[
        {"id":1,"name":"John Doe"},
        {"id":2,"name":"Don Joeh"}
    ]},
    {"othertype":[
        {"id":2,"company":"ACME"}
    ]}]
},{"otherstuff":[
    {"thing":
        [[1,42],[2,2]]
    }]
}]}

If I fetch this object into a variable called "result" I have to access the nested objects like this:

result.data[0].stuff[0].onetype[0]

and

result.data[1].otherstuff[0].thing[0]

This seems clumsy and redundant to me, if possible I would prefer:

result.stuff.onetype[0]

and

result.otherstuff.thing

But how can I use the object keys directly when everything is an array? To my confused and uneducated mind something like this would seem more appropriate:

{"data":
    {"stuff":
        {"onetype":[
            {"id":1,"name": ""},
            {"id":2,"name": ""}
        ]}
        {"othertype":[
            {"id":2,"xyz": [-2,0,2],"n":"Crab Nebula","t":0,"c":0,"d":5}
        ]}
    }
    {"otherstuff":
        {"thing":
            [[1,42],[2,2]]
        }
    }
}

I’ve probably misunderstood something fundamental here, but I cannot get the jQuery parser (nor the native FF parser used by jQuery 1.4) to accept the second style object. If anyone can enlighten me it would be gratefully appreciated!

  • 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-13T11:43:46+00:00Added an answer on May 13, 2026 at 11:43 am

    You don’t need to use arrays.

    JSON values can be arrays, objects, or primitives (numbers or strings).

    You can write JSON like this:

    { 
        "stuff": {
            "onetype": [
                {"id":1,"name":"John Doe"},
                {"id":2,"name":"Don Joeh"}
            ],
            "othertype": {"id":2,"company":"ACME"}
        }, 
        "otherstuff": {
            "thing": [[1,42],[2,2]]
         }
    }
    

    You can use it like this:

    obj.stuff.onetype[0].id
    obj.stuff.othertype.id
    obj.otherstuff.thing[0][1]  //thing is a nested array or a 2-by-2 matrix.
                                //I'm not sure whether you intended to do that.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out if there is any way to have a .NET
is there any way to make IE6 understand double classes, say I have a
Is there any way to have something that looks just like a file on
Is there any way to have PHP automatically call a function, before a script
Is there any way to have a Windows batch file directly input SQL statements
Is there any way to have a dropdown in excel that will show a
Is there any way to have the QCompleter to act like an autocomplete for
Is there any way to list all the files that have changed between two
Is there any way to do it? I only have client access and no
Let's say you have a class with a Uri property. Is there any way

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.