R
R
rama_jecboom2021-01-25 21:11:32
JSON
rama_jecboom, 2021-01-25 21:11:32

How to get information from json?

Help write a script.
It is necessary that, if on the server in json, for example, it is written

{
  "start": "true"
}

Then another scene opens, and if false, then it is written that the servers are disabled and that's it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grish Poghosyan, 2021-01-25
@hovsepyann

Install Newtonsoft.Json from NuGet

string json = "{ \"start\": \"true\" }";
    
JToken token = JObject.Parse(json)["start"];
bool start = Convert.ToBoolean(token);
    
if(start) Console.WriteLine("It's true");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question