Answer the question
In order to leave comments, you need to log in
Did I choose the right JSON structure?
Actually a question. Which JSON option is better/correct.easier to bypass.
{
"date": 2012-05-14,
"tags": {
"Python": 1,
"Java": 3,
"Linux": 8
},
"status": 0
}
{
"date": "2012-05-14",
"tags": [
{"Python": 1},
{"Java": 3},
{"Linux": 8}
],
"status": 0
}
Answer the question
In order to leave comments, you need to log in
It all depends on the destination. In the first one, the tags object is guaranteed to contain one language (key) each. This can be said to be safer, but if you need several such keys (languages), then the 2nd option is better. However, the 2nd option will be more difficult to process (if you need to know the selected key (language)). This is how it will be better (for the 2nd option):
{
"date": "2012-05-14",
"tags": [
{"id": "Python", "value": 1},
{"id": "Java", "value": 3},
{"id": "Linux", "value": 8}
],
"status": 0
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question