deserialize json to general object (without predefined schema)

user1025852

I'm trying to use json.net.

I'd like to get a string (in json format) and convert it to general json object, without predefined schema.

somelting like

 var jsonString = @"{\""id\"": 1,\""name\"": \""A green door\""}";    
 var jsonMessage = JsonConvert.DeserializeObject<JObject>(jsonString);    
 var myValue = jsonMessage["name"]

Is that something doable? didn't make it work

Andrew Whitaker

Your string is malformed, try this string instead:

var jsonString = "{\"id\": 1,\"name\": \"A green door\"}";    

You could also shorten this a little bit:

string name = JObject.Parse(jsonString)["name"].ToObject<string>();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

deserialize inner JSON object

From Dev

Deserialize a JSON Schema with JSON.Net

From Dev

Cannot deserialize Json to object

From Dev

Deserialize stringified JSON object

From Dev

deserialize json to general object (without predefined schema)

From Dev

Deserialize Json to Object Exception

From Dev

JSON Convert Deserialize Object

From Dev

How to deserialize JSON to object in Swift WITHOUT mapping

From Dev

JSON Schema: verifying object's values, without keys

From Dev

Type of object in byte[] to deserialize with schema?

From Dev

Deserialize Json object into a list?

From Dev

Deserialize JSON Object into Class

From Dev

JSON Deserialize Object not working

From Dev

Deserialize Json to Object in a constructor

From Dev

JSON Deserialize Object HTTPWebResponse

From Dev

Avro: deserialize json - schema with optional fields

From Dev

newtonsoft json schema deserialize ValidationError

From Dev

Json deserialize object empty

From Dev

Deserialize object using JSON.NET without the need for a container

From Dev

DeSerialize Json into Class object

From Dev

Cannot deserialize a JSON object

From Dev

Deserialize JSON object

From Dev

Newton JSON deserialize to an object

From Dev

Type of object in byte[] to deserialize with schema?

From Dev

Deserialize Json to Object in a constructor

From Dev

JSON.net deserialize JSON without schema

From Dev

Newtonsoft JSON Schema Ignore Validations For Deserialize

From Dev

Json Deserialize Object crashing

From Dev

BigQuery Jobs insert without any predefined schema