Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  127] [ 3]  / answers: 1 / hits: 18931  / 6 Years ago, tue, june 26, 2018, 12:00:00

I am working on a project that has JSON format output. I need a clarity on the JSON array structure. So There are fields that are multiple entry like an array. If an element is an array but has only one value, does it still include an array node '[' in the structure?



Example:



This is a sample JSON element which is an array and has multiple values.



Talents: [
{
Items: test
},
{
Items: test
}
]


If this element does not have multiple values, will it appear as below?



   Talents: 
{
Items: test
}


The '[' does not appear for an array type element with single value. Can someone Pls clarify this?


More From » arrays

 Answers
30

Square brackets ([]) denotes JSONArray which in your case can access like



Talents[0]


will return



      {
Items: test
}


In second case, curve brackets denotes an JSON object. If you want to access value of items. Than you can by



Talents.Items


OR



Talents[Items]


will return



Test


for complete reference,
JSON Syntax


[#54116] Friday, June 22, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carterf

Total Points: 255
Total Questions: 93
Total Answers: 122

Location: Marshall Islands
Member since Wed, Jun 17, 2020
4 Years ago
;