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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:44:53+00:00 2026-06-03T14:44:53+00:00

I am having difficultly with syntax and structure of JSON objects/arrays. { accounting :

  • 0

I am having difficultly with syntax and structure of JSON objects/arrays.

{ 
  "accounting" : [   
                     { "firstName" : "John",  
                       "lastName"  : "Doe",
                       "age"       : 23 },

                     { "firstName" : "Mary",  
                       "lastName"  : "Smith",
                        "age"      : 32 }
                 ],                            
  "sales"      : [ 
                     { "firstName" : "Sally", 
                       "lastName"  : "Green",
                        "age"      : 27 },

                     { "firstName" : "Jim",   
                       "lastName"  : "Galley",
                       "age"       : 41 }
                 ] 
} 

I want to make a nested structure of objects and arrays that would house the following info:

{
"problems": [{
    "Diabetes":[{
        "medications":[{
            "medicationsClasses":[{
                "className":[{
                    "associatedDrug":[{
                        "name":"asprin",
                        "dose":"",
                        "strength":"500 mg"
                    }],
                    "associatedDrug#2":[{
                        "name":"somethingElse",
                        "dose":"",
                        "strength":"500 mg"
                    }]
                }],
                "className2":[{
                    "associatedDrug":[{
                        "name":"asprin",
                        "dose":"",
                        "strength":"500 mg"
                    }],
                    "associatedDrug#2":[{
                        "name":"somethingElse",
                        "dose":"",
                        "strength":"500 mg"
                    }]
                }]
            }]
        }],
        "labs":[{
            "missing_field": "missing_value"
        }]
    }],
    "Asthma":[{}]
}]}

But I have no idea what the right way to do this should be. Should I just be making JavaScript objects? Does JSON make sense for this project?

What is the correct syntax to set something like this up?

Here is my code so far:

$(document).ready(function() {
    $.getJSON('js/orders.json', function(json) {
      $.each(json.problems, function(index, order) {
        $('.loadMeds').append('<p>' + order.name + '</p>')
      });
    });
});
  • 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-03T14:44:57+00:00Added an answer on June 3, 2026 at 2:44 pm

    The first code is an example of Javascript code, which is similar, however not JSON. JSON would not have 1) comments and 2) the var keyword

    You don’t have any comments in your JSON, but you should remove the var and start like this:

    orders: {
    

    The [{}] notation means “object in an array” and is not what you need everywhere. It is not an error, but it’s too complicated for some purposes. AssociatedDrug should work well as an object:

    "associatedDrug": {
                    "name":"asprin",
                    "dose":"",
                    "strength":"500 mg"
              }
    

    Also, the empty object labs should be filled with something.

    Other than that, your code is okay. You can either paste it into javascript, or use the JSON.parse() method, or any other parsing method (please don’t use eval)

    Update 2 answered:

    obj.problems[0].Diabetes[0].medications[0].medicationsClasses[0].className[0].associatedDrug[0].name
    

    returns ‘aspirin’. It is however better suited for foreaches everywhere

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having difficulty trying to design a database structure for the following scenario: My
I'm having difficulty translating sql to linq syntax. I have 2 tables (Category and
I'm having difficulty getting the correct syntax for a template specialisation which accepts a
I am learning how to handle subviews and I am having difficultly manipulating the
If f = O(g) , is e^f = O(e^g) ? I'm having difficultly figuring
I am applying the MVVM pattern per Josh Smith and having difficulty. I've been
I'm having difficulty understanding the syntax of C++ Template Template parameters. I understand why
I'm having difficulty with Oracle 10g syntax for a correlated UPDATE. I am processing
I am having difficulty understanding the proper syntax for the second default value in
I'm having difficultly figuring out how to write this block of code... function myFunction(x,y,z)

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.