W
W
Way2017-06-22 10:09:05
Java
Way, 2017-06-22 10:09:05

How to create layered json?

Good afternoon, I am writing a small program to store data received from the server in json, but there is a lot of data and I have to group them, and then internal data too. Those. you need something like this in java:

{
  "server_1": {
    "group_1": {
      "client_1": {
        "name": "George",
        "position": {
           "x": "12",
           "y": "24",
           "z": "14"
           "family": {
        	  more arrays...
           }
        }
      }
    }
  }
}

How to do this? Which is better suited for HashMap or classes or is there a simpler solution for such purposes? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Myvrenik, 2017-06-22
@gim0

You need to look at JSON objects ( { ... }) specifically as objects in OOP, and not as an associative array. Create specific models with all the relationships between them that you are going to serialize in JSON. If you need a list of servers / groups / clients, then use the list ( [ ... ]) of serialized models.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question