Get only some part from JSON using C#
I have a Json value that I want to get only some part of it and ignore the other keys. public class MyClass { public long? id { get; set; } public Order order{ get; set; } } public class…
I have a Json value that I want to get only some part of it and ignore the other keys. public class MyClass { public long? id { get; set; } public Order order{ get; set; } } public class…
I'm trying to convert JSON responses, in which all keys are in snake_case, for example { "op": 0, "t": "some_name", "d": { "heartbeat_interval": 10000, "user": { "user_id": 1 } } } (This is just one of the many things that…
I'm using newtonsoft json, and I need to serialize/deserialize this kind of json: [ { "value": "value1", "field": "field1" }, { "value": "value2", "field": "field2" }, { "value": "value3", "field": "field3" }, [ { "value": "value4", "field": "field4" }, {…
In a file path I have a few json files and I'm trying to consolidate them into one file using C# newtonsoft json. JSON1: [{ "name": "name1", "salary": 65000 }, { "name": "name2", "salary": 68000 } ] JSON2: [{ "name":…
I want to display the list of state and city from a column inside my database into two lookupedit. The following is the list for state and city that I've put inside a column my sql server: [ { "State":…
How do I deserialize an object from JSON format with valid data using JsonConvert.DeserializeObject(useCaseData)? I tried it with JsonConvert.DeserializeObject<Dictionary<string, string>>(useCaseData) But I get this error : Newtonsoft.Json.JsonSerializationException: 'Error converting value 1 to type 'System.Collections.Generic.Dictionary`2[System.String,System.String]'. Path '', line 1, position 1.…
I am trying to convert an XML to JSON without changing the datatypes but it is always returning the string value. I have tried different ways to convert with proper data types. Below is my source XML and expected JSON…
I'm trying to iterate through all "DicomModalities" in the following json string and get data in the following format but my code isnt working and gives the error "'name' is not a member of 'JObject'" required format >>> (dicommodality name)-AET…
I'm trying to deserialize a JSON object. The value of the string 'plaintext' is: {"expiryDay":1,"expiryMonth":6,"expiryYear":2023,"machineGuid":"a3586fb9-b05e-46f1-a4a0-683a97109e34","name":"Alexander Farley"} This line throws an exception: var json = JObject.Parse(plaintext); The exception is: Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: . Path '',…
Im trying to get a list of all the "Occupants" and "RiskId" from the JSON below using C# and Newtonsoft. Not sure what I'm doing wrong here. Thanks for your help. { "Header": { "MatchType": "Exact", "TotalResultCount": 2, "PreviousPageUrl": null,…