Ahmed
Ahmed

Reputation: 19

Hello gurus, Could someone please tell me what's wrong with my JSON syntax string?

I am POSTing this to a URL but the other side is only picking up the last K+ LabResultItem. Here is my JSON string:

"LabResultItems": [
   {
    "LabResultItem": {
     "AnalyteName": "pH",
     "Result": "7.4",
     "Units": "mmHg"
     },
    "LabResultItem": {"
     "AnalyteName": "pO2",
     "Result": "31.0",
     "Units": "mmHg"
     },
    "LabResultItem": {
     "AnalyteName": "pCO2",
     "Result": "33.4",
     "Units": "mmHg"
     },
    "LabResultItem": {
     "AnalyteName": "K+",
     "Result": "42.0",
     "Units": "mmHg"
     }
   }
]

Thank you.

Upvotes: 0

Views: 39

Answers (2)

Priyadeep Datta
Priyadeep Datta

Reputation: 34

please try the one below

{
  "LabResultItems": [
    {
      "AnalyteName": "pH",
      "Result": "7.4",
      "Units": "mmHg"
    },
    {
      "AnalyteName": "pO2",
      "Result": "31.0",
      "Units": "mmHg"
    },
    {
      "AnalyteName": "pCO2",
      "Result": "33.4",
      "Units": "mmHg"
    },
    {
      "AnalyteName": "K+",
      "Result": "42.0",
      "Units": "mmHg"
    }
  ]
}

Upvotes: 1

jwodder
jwodder

Reputation: 57510

"key": value structures must be contained within { ... } in order to form a dictionary/object, but "LabResultItems": ... is not. You need to wrap your near-JSON in { and }.

Upvotes: 0

Related Questions