Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating Json nested file structure

I am trying to add year and month to a json file so i can group all parties and events into a month with out having to place this information in each event but when I add it at the top of file it wont parse I am having a syntax issue some where here.

{

"year": 2023,
"month": 12
 {
  "Parties": [
    {
      "Event1": 67.7,
      "Event2": 5.1,
      "Event3": 3.3

    },
    
    {
       "Event1": 89.7,
       "Event2": 4.3,
       "Event3": 3.2
    
    },
    {
       "Event1": 69.3,
       "Event2": 4.2,
       "Event3": 0.0
    
    }
   ]
 }
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

There is a typo (comma is missing after month) and extra curly bracket { you have.

The working JSON is:

{
  "Year": 2023,
  "Month": 12,
  "Parties": [
    {
      "Event1": 67.7,
      "Event2": 5.1,
      "Event3": 3.3
    },
    {
      "Event1": 89.7,
      "Event2": 4.3,
      "Event3": 3.2
    },
    {
      "Event1": 69.3,
      "Event2": 4.2,
      "Event3": 0
    }
  ]
}

or if you want to use nested JSON, then add a property name before "Parties"

{
  "Year": 2023,
  "Month": 12,
  "PartyData": {
    "Parties": [
      {
        "Event1": 67.7,
        "Event2": 5.1,
        "Event3": 3.3
      },
      {
        "Event1": 89.7,
        "Event2": 4.3,
        "Event3": 3.2
      },
      {
        "Event1": 69.3,
        "Event2": 4.2,
        "Event3": 0
      }
    ]
  }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading