Filter deserialized results on a specific value from array of JSON objects?

I am getting JSON responses from API: "table1": [ { "abc": "test", "def": "test1" }, { "abc": "test2", "def": "User1" } ] which is binding into public List<object>? table1 { get; set; } I want to get the User1 using Linq/Lamda. Below returns 0 record: var filteredList = table1 .Where(item => item.GetType().GetProperty("def",BindingFlags.Instance | BindingFlags.Public |… Read More Filter deserialized results on a specific value from array of JSON objects?

Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: {. Path

I’m trying to parse a string to JSON, and it works if I parse it to JObject, but if I try to parse to my own custom type, I’m getting an error when it tries to parse the Properties property error: Newtonsoft.Json.JsonReaderException: ‘Unexpected character encountered while parsing value: {. Path ‘Properties’, line 1, position 212.’… Read More Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: {. Path

How to pass string variables to JObject C# – Could not load file or assembly 'System.Text.Json

Good day, I need to assign variables to JObjet: JObject json = JObject.Parse(@"{ RequestData: { AccountCredential: { AccountLink: ‘dFyRCVYNM0aGb1LSR/0B8e+eSVr1Zf1xj9YHmMVoiZWk28XtWEyIxEbGXnr1EdvS+QBPzjweau7tbf5QlDv97IQ2jwfUB==’ }, AccountNumber: ‘000011887755’, BookingDateStart: ‘2022-07’, BookingDateEnd: ‘2022-07’ } }"); I want to pass values ​​to AccountLink, AccountNumber, BookingDateStart, BookingDateEnd. If you notice, I set the values ​​to hard, but these change, where I should use it… Read More How to pass string variables to JObject C# – Could not load file or assembly 'System.Text.Json

Is there a way to get list of specific element in JSON using C# and Newtonsoft

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, "NextPageUrl": null, "AvailableProductsForRequestedAddress": "https://prometrixapiuat.iso.com/uw/address/productList?City=MONTEBELLO&State=CA&StreetName=423+W+OLYMPIC+BLVD&Zip=90640&quot; }, "Risks": [ { "RiskId": "64CX99016399", "BuildingDescription": "MONTEBELLO PLASTICS INC (1S)",… Read More Is there a way to get list of specific element in JSON using C# and Newtonsoft

Newtonsoft.Json DeserializeObject not working

I have a very simple JSON file: [ { "smbshare": { "name": "Backup", "path": "\\linuxserver\backup" }, "smbshare2": { "name": "Tools", "path": "\\linuxserver\tools" } } ] My model class: public class SmbShare { [JsonProperty("name")] public string Name { get;set; } [JsonProperty("path")] public string Path { get; set; } } And the SmbController public class SmbController :… Read More Newtonsoft.Json DeserializeObject not working

JsonSerializer.Deserialize always returns Null

Trying to deserialize the following json string: string json = "{\"d\":{\"__metadata\":{\"id\":\"http://my.dev.int:8000/sap/opu/odata/sap/ZFIORI_SERIAL_NUMBERS_SRV/MATERIALSet(‘250&#8217;)\",\"uri\":\"http://my.dev.int:8000/sap/opu/odata/sap/ZFIORI_SERIAL_NUMBERS_SRV/MATERIALSet(‘250&#8217;)\",\"type\":\"ZFIORI_SERIAL_NUMBERS_SRV.MATERIAL\"},\"MATNR\":\"250\",\"MAKTX\":\"X:K10/MF250\"}}"; into Class Object namespace Scanner.Model { public class Material { public string MATNR { get; set; } public string MAKTX { get; set; } } } I have tried using many ways including : Material material = JsonSerializer.Deserialize<Material>(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true,… Read More JsonSerializer.Deserialize always returns Null