4

I'm looking for a way to deserialize a string coming from an API. The Json string is just : {"key" : "lolo"}.

I dont want to create a class for this. I have found this but it's kind of old so I don't know if there is something better today: Json deserialize

In the future I will use more Json deserialization so I would like to use JSON.NET. Thanks.

Community
  • 1
  • 1
king
  • 507
  • 1
  • 4
  • 17
  • 1
    Duplicate of http://stackoverflow.com/questions/4535840/deserialize-json-object-into-dynamic-object-using-json-net or http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object – Zoran P. Mar 07 '15 at 08:19

1 Answers1

-1

Have a look at this: http://www.newtonsoft.com/json.

Used in almost every .net appilication these days.

null
  • 7,906
  • 3
  • 36
  • 37
  • Thanks, but in the top right corner, the examples. He create a Movie class. And I don't want to create a class for one value. – king Mar 07 '15 at 08:25
  • 5
    You can also deserialize to dictionaries: `JsonConvert.DeserializeObject>("{ \"foo\": \"bar\" }")` – null Mar 07 '15 at 08:36
  • 1
    @null This should be a part of the answer as it is the main argument why using netwonsofts library would work. – C4d Jan 25 '18 at 15:50
  • Use **dynamic** datatype. like - `dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject(result.ToString());` – SpikeEdge Feb 07 '21 at 23:57