H
H
hobzy2022-04-12 10:59:41
JSON
hobzy, 2022-04-12 10:59:41

How to add objects and arrays to Json through different loops in c#?

For me, Json c# is a new topic (
Here is my json structure:

{
  "ArrayDir":[+
    "8ADEC9BCFC11D084C5D216F97135F437|1",
    "8ADEC9BCFC11D084C5D216F97135F437|2",
    "8ADEC9BCFC11D084C5D216F97135F437|3"
  ],
  "DirInfo":{@
    "8ADEC9BCFC11D084C5D216F97135F437|1":{@
      "UserList":[+
        "76561199139107522|1",
        "76561199139107522|2",
        "76561199139107522|3"
      ],
      "User":{@
        "76561199139107522|1":{@
          "InventoryStatus":{@
            "STATUS":true,
            "GameCSGO":true,
            "GameDOTA":true,
            "GameRUST":true
          },
          "InventoryList":{
            "CSGO":[+
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>"
            ],
            "DOTA":[+
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>"
            ],
            "RUST":[+
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>",
              "Кейс <Решающий момент>"
            ]
          },
          "InventoryMoney":{@
            "CSGO":"1000.00", 
            "DOTA":"1000.00", 
            "RUST":"1000.00" 
          }
        }=
      }
    }=
  }
}

Where there is a = sign, I will supplement with similar objects
Where there is a + sign, I will fill arrays
Where there is an @ sign, I will fill in objects
I could not find an example in c # how to fill this whole thing with cycles

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2022-04-12
@freeExec

Normal people deserialize all this into classes, and add objects to lists and dictionaries as usual. And then serialized back to json.
https://docs.microsoft.com/en-us/dotnet/standard/s...
But of course you are free to try to work directly with the text.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question