Questions tagged [json-deserialization]

JSON deserialization is the process of converting a JSON string into an instance of an object, often a class.

JSON (Object Notation) is an efficient data encoding format that enables fast exchanges of small amounts of data between client browsers and -enabled Web services.

JSON deserialization is the process of converting a JSON string into an instance of an object, often a class. JSON encoded strings carry both structural and data information, so the instance of the object resulting from deserialization is a well-defined, data-filled object.

For example the following string:

string json_encoded_string = @"{""name"" : ""John"", ""surname"" : ""Doe"", ""age"" : 38}";

can be deserialized into an instance of the following class:

class Person
{
    public string name { get; set; }
    public string surname { get; set; }
    public int age { get; set; }
}
2322 questions
0
votes
2 answers

convert array in json to c# dictionary

i have this json string: {"products": [{"id": 22,"date_add": "2021-06-17 19:21:26","date_upd": "2021-07-12 13:02:01","name": [{"id": "1","value": "Product 1"}, {"id": "2", "value": "Product 1"}]}}, {"id": 1,"date_add": "2021-06-17…
Jana
  • 13
  • 2
0
votes
0 answers

Springboot Deserializing ">" symbol as > and "<" as <

I have a post api built in springboot with request body as follows { "value" : ">" } When this value is passed to the api as payload, the deserilized value in the controller is coming as > . the request body in java is as follows public class…
Sudharnath
  • 11
  • 2
0
votes
1 answer

How to deserialize nested JSON object to class in test where nested object is type dynamic

I am working on .NET 5 API application xUnit Tests. I am receiving JSON object in the following format. In the JSON object, I have an nested object with the title 'data'. I need to deserialize data object into class. The data object is of type…
K.Z
  • 5,201
  • 25
  • 104
  • 240
0
votes
3 answers

Deserialize json without property names

I want to deserialise the json string below which doesn't use property names for the bids or asks. This is what my classes look like: public class OrderBook { public long lastUpdateId { get; set; } public List Bids { get; set; } …
Ron Splinter
  • 151
  • 3
  • 14
0
votes
2 answers

Jackson cannot deserialize single field class, although Creator exists

I have the following simple jUnit test: class MyTest { static class SingleField { int rank; SingleField(int rank) { this.rank = rank; } @Override public boolean equals(Object o) { …
Jason
  • 2,495
  • 4
  • 26
  • 37
0
votes
1 answer

Deserializing JSON Object from JsonConvert returns null

Without serializing getting data from API response var apiResponseDetails = authorityApiResponse.Content.ReadAsStringAsync().Result; "[ { \"k__BackingField\":\"L5 _Admin _Role\", \"k__BackingField\":\"565,1\" …
0
votes
1 answer

C# Newtonsoft.Json DeserializeObject if json contains an invalid token

How can i deserialize this json in C# using Newtonsoft.Json.JsonConvert.DeserializeObject? The problem is that i cannot use "event" as a class property because its an invalid token. { "resultsPage": { "results": { "event": { …
Udo
  • 43
  • 6
0
votes
3 answers

How to Loop through serialized json

Res={"result":["123","563"]} This is the similar json file i have. I have to loop through it and assign each value as ids. I am trying as Obj = JsonConvert.DeseraializeObject(Res); Foreach(string id in Obj) {Function();} I'm getting…
Tt11
  • 9
  • 3
0
votes
3 answers

What should be the Kotlin class to represent a json with array of classes

Given the following JSON: { "from": 1, "to": 3, "results": [ { "item": { "status": "SUCCESS", "statusMessage": "", "requestId": "1" } }, { "item": { "status":…
0
votes
1 answer

How to deserialize enum and array in .NET 5

jqgrid filter deserialization in ASP.NET 5 MVC application fails using System.Text.Json.JsonSerializer To reproduce, run the code var _filters ="{\"groupOp\":\"AND\",\"rules\":[{\"field\":\"Toode\",\"op\":\"cn\",\"data\":\"\"}]}"; var filtersList =…
Andrus
  • 26,339
  • 60
  • 204
  • 378
0
votes
1 answer

Jackson deserialization interface on multiple types

I'm experimenting some troubles with Jackson deserialization in Java. I've made 2 solutions, and I can't resolve the problem. Problem? I got my result with the property duplicated, a field it's duplicated after jackson deserialization. (My problem…
0
votes
0 answers

jackson deserialize json to object without annotation

I have old Pojos inside jar. Example; public class human implements Serializable { } public class Man extend human { } public class Woman extend human { } I have json like {"type":"man",...} I want to deserialize proper class…
0
votes
4 answers

How can i deserialize my json in Flutter/dart

I'm quite new to flutter and right now i'm stucked in desterilize the json string into my class. Appreciate your help on this. This is my json [ { "itemno": "4800888136473", "itemname": "AXE DEO AFRICA 150ML", }, { "itemno":…
0
votes
1 answer

Deserializing an array of strings using Rest Template in Java

I am making an api call and the json is returning as an array of strings. How do I deserialize an array of strings? They do not include a key of any kind so the usual way I would deserialize is not working. This is using the league of legends api…
Dan
  • 77
  • 1
  • 10
0
votes
1 answer

Why is Newtonsoft converting a missing integer field to its default value in F#?

When using Newtonsoft for deserializing a JSON object in F#, I noticed that the deserialization process converts the missing integer fields to its default values. In the following example, the missing integer field in instanceB is converted to an…
Robur_131
  • 674
  • 1
  • 5
  • 16