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
1 answer

Spring Boot - JSON Deserialization

I am getting nested json object and json array as response while making ReST call. Nested json array and json object comes randomly. It may not be present as part of response everytime. I want to deserialize json in such a way that all the fields in…
0
votes
3 answers

Json to C# models problem a class always returns null

Here is my json example: { "generated_at": "2020-11-24T11:27:57+00:00", "summaries": [ { "sport_event": { "id": "sr:sport_event:22762631", "start_time": "2020-11-24T10:00:00+00:00", …
mko1995
  • 15
  • 3
0
votes
1 answer

How to deserialize JSON with dynamic keys in dart

Following is the api response I have { "19ca14e7ea6328a42e0eb13d585e4c22":{ "key":"19ca14e7ea6328a42e0eb13d585e4c22", "product_id":36, "variation_id":0, "variation":[], "quantity":1, …
Sachin Soma
  • 3,432
  • 2
  • 10
  • 18
0
votes
1 answer

Deserializing JSON Response

I am using RestSharp to call an API which is returning JSON. I send the API a list of IDs and the API returns info for each ID in some JSON array with key being the ID. What is the best approach to deserialize this dynamic info into C# objects? var…
xMetalDetectorx
  • 160
  • 1
  • 14
0
votes
1 answer

Deserialization of json file

I'm having a hard time deserializing a JSON file I'm getting from an API. This is the class structure I have created based on the file: namespace Huskeliste { public class RecipeClass { public class Rootobject { public string q { get; set; } …
majo
  • 1
  • 2
0
votes
1 answer

Jackson annotations - Unmarshall array as object by mapping index to property

I am reading from a stream that provides updates to an order book used to calculate market depth. Each includes a list of new entries for the order book. Each entry contains three properties. Market side (e.g. buy or sell) Quantity transacted of…
0
votes
1 answer

How to deserialize JSON Array to Apache beam PCollection

I have data like [{"ProjectId":1476401625,"ProjectName":"This is project name","ProjectPostcode":4178},{"ProjectId":2343,"ProjectName":"This is project 2 name","ProjectPostcode":5323}] I need to to deserialize it to Java object and I use this code…
0
votes
1 answer

C# Json - JSONproperty of Various Data Types. .net 3.5

Trying to figure out how to Serialize or Deserialize (JSON) an object, that has a value property that can be a bool, number, or string. "object": { "id":"someID", "value": -10 or true or "someString" } I expect I will need to use JSONConvert,…
Angryjames
  • 77
  • 9
0
votes
1 answer

Spring Response Object to Json String in a Unit-Test

I have a spring boot rest controller which returns an object. Something like this: @RestController @RequestMapping("books-rest") public class SimpleBookRestController { @GetMapping("/{id}", produces = "application/json") public…
myborobudur
  • 4,385
  • 8
  • 40
  • 61
0
votes
1 answer

Deserialize JSON into C# dynamic object throw OutOfMemoryException exceptio

I am using a C# dynamic functionality to deserialize Json. It is working perfectly for small file. However if the data file becomes large(I am testing with 500mb file) the deserializer will throw memory exception like below. >Message: Exception of…
xChaax
  • 193
  • 5
  • 27
0
votes
1 answer

Is there any option to register Serializer/Deserializer only once for java.time.* packages using Jackson in Spring Boot?

Hello Team, I am working on a Spring Boot Project (Version 2.3.4 Release) in which I am using java.time.LocalDate, java.time.LocalDateTime and java.time.LocalTime datatypes for some of the properties in several beans. However, these fields are not…
0
votes
1 answer

Nested Deserialization of a Very Long Object - From Json to C#

I want to deserialize the following string object (JSON String) into a C# List. Please note this is in JSON format, not with C# escape characters etc. { "2020-01-01": { "price" : 100 }, "2020-01-02": { "price" : 101 }, …
0
votes
1 answer

Deserialize JSON into an array of class instances using Symfony Serializer

I'm trying to deserialize JSON into a DTO class, which has a property types as NestedDto[]. Unfortunately, the objects inside the array are deserialized as arrays, not instances of NestedDto. My DTO classes are like: class TestDto { /** *…
Marian
  • 3,789
  • 2
  • 26
  • 36
0
votes
2 answers

Newtonsoft.Json DefaultContractResolver remove key from dictionary

I have the following class (I don't want to change the class to solve the issue..): public class Test { public Dictionary Data; [PrivateField] [JsonIgnore] public string Name { get { return Data["Name"]; } set {…
K.Moment
  • 1
  • 2
0
votes
1 answer

Error while deserializing the JSON of float array with Newtonsoft.Json in C# console app

I'm using Newtonsoft.Json library and i can't acomplish a rather simple task: Serialize an array of floats and then deserialize the same file. My console aplication looks like this: var x_train = new float[3]; x_train[0] = 0.23f; x_train[1] =…
1 2 3
99
100