T
T
the5x2019-09-20 17:46:58
JSON
the5x, 2019-09-20 17:46:58

How to learn how to properly build JSON architecture?

How to learn how to properly build JSON architecture? Difficulties arise when you need to create JSON from scratch. When you need to wrap in an object, when an array in an object, when just an array. Explain how to learn how to create proper JSON architecture with data?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Developer, 2019-09-20
@samodum

JSON is just an object that is serialized and deserialized as a JSON string.
Therefore, the question here is not about JSON itself, but about the object representation model itself, the object model itself.
And in general, there is no correct architecture, and it is not needed. json is just a dataset, its structure is not important

D
dollar, 2019-09-20
@dollar

That's right, whatever is convenient.
That is, convenience is the main criterion for correctness.
For example, if an object has hundreds of properties, it would be convenient to break them down into categories. If properties have numbers rather than names, then using an array is more logical than an object. Etc.

S
Sunflowerz, 2019-09-25
@Sunflowerz

https://jsonformatter.curiousconcept.com/ - json correctness validator
https://www.json.org/json-ru.html - I studied the structure here a year ago

P
ProgPHP, 2019-09-29
@ProgPHP

Look, if you need to display a lot of elements, then it's like this:

{
    "response": {
    "count": 1,
    "items": [
    {
      "user_id": 1
      "screen_name": "test 1",
      
    },
                {
      "user_id": 2
      "screen_name": "",
      
    }
                ..................
    ]
  }
}

And if you need to display one element, then like this:
{"response": {
        "user_id": 1,
        "screen_name": "test"
     }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question