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

c# Deserialize JSON to 3 classes

I have spent 2 days on this problem and still have not solved this... The Json comes from Firebase Realtime Database. My absolute goal would be to get the key (Zaptec) as name in the class instead of having to create a "name" property. But that is a…
0
votes
1 answer

Deserialize IRestResponse and write out to console, C#

I'm using CalorieNinjas API to build a simple console app in C#. User enters an ingredient and the API returns various nutrition values in JSON format: JSON output The problem on my side is, that I don't know exactly how to deserialize the JSON…
awertol
  • 5
  • 3
0
votes
2 answers

Jackson- How to process the request data passed as JSON (Netsed Json)?

{ "DistributionOrderId" : "Dist_id_1", "oLPN": { "Allocation": { "AID": "12345" }, "Allocation": { "AID": "123456" , "SerialNbr": "SRL001", …
0
votes
1 answer

jackson deserialize parent object

I use jackson to deserialize an java object LivingBeing which has Animal class in it. So far I was dierctly passing object of Animal. class LivingBeing { @JsonProperty('animal') Animal animal; } class Animal { @JsonProperty('color') String…
drk
  • 153
  • 1
  • 17
0
votes
1 answer

How to model a target class for receiving a JSON html response in .NET5

I'm trying to read a list of objects from a public WEB Api that provides a JSON file with an array of objects, I'm using Blazor and the Net 5 platform. The de-serialization fails with this error: System.Text.Json.JsonException: The JSON value could…
0
votes
1 answer

How to proper relate(group) Entities in Symfony and api-platform

Im getting the error: Nested documents for attribute "players" are not allowed. Use IRIs instead. So, I understand that I need to make groups with a serializer. What im working with; I use symfony 5, doctrine(SQLite) and api-platform. Im making a…
0
votes
1 answer

Deserializing a Json array of objects in xamarin forms not working

I have a json api response of something like this: [ { "id": 1, "accountnumber": "001303000023", "accounttitle": "MEGA CROWN ", "accountdesc": "MEGA CROWN ", "productType": "Loan", "prodname": "SME TERM LOAN …
DevLayi
  • 55
  • 10
0
votes
0 answers

C# ReadAsAsync - System out of memory issue

I have a WEB API which returns some data which includes large byte array [file size is 400 MB] Now i am getting a response from API but while putting it into my class, i am getting an error as - Exception of type 'System.OutOfMemoryException' was…
0
votes
1 answer

Converting/Deserializing a JSON with an ArrayList of ArrayList without a Key

I have a json file with multiple arrays. It is not clear to me how to set up Key-Value pairs when this isn't one given. I understand that a [ … ] represents an array and { … } represents an object. I looked at tutorials online but none had an…
PTJBlue
  • 3
  • 2
0
votes
1 answer

Adding a dictionary to an array in an existing json file

I have a local json file that I wish to be able to add a new dictionary to the existing array within the file using data entries from a form. i.e. turn this: [ { "name": "Product1", "type": "Drink", "costS": 2.5, "costB": 2.4, …
Greefin
  • 3
  • 1
0
votes
0 answers

Deserialize anonymous jagged JSON array c#

I have an API endpoint which is receiving a data string which looks like the following: "[[0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0],[[],[],[],[[17.637329000012972,17.637329000012972]],[],[],[],[],[]]]" I would now like to convert this json object into an…
Ryan
  • 233
  • 2
  • 9
0
votes
1 answer

Deserializing JSON from webpages - Always the wrong Syntax?

I'm trying to scrape pages, find their schema.org script, then deserialize it. I am able to find the script, however, valid JSON schema (according to Google/schema.org) is supposedly invalid in most Json Validator tools. For example, this is my…
MattHodson
  • 736
  • 7
  • 22
0
votes
2 answers

Deserialize JSON string when there is dynamic type JSON array in that object

I have a JSON string like this { Success :1,PageNumber :1,TotalPages :5,Data:[{projectName:'Pr1',ProjectId:'p3452'},{projectName:'Pr2',ProjectId:'p5485'}....] } Here is my class structure for that public class KipReport { public bool…
Sandeep Thomas
  • 4,303
  • 14
  • 61
  • 132
0
votes
1 answer

Deserialize nested JSON into C# childObject classes

I want to get nested json object result after its deserialization as in following code. var matrixDto = new QuestionMatrixDto(); // First child Dto: matrixDto.displayAnswers = "displayAnswers Test"; matrixDto.questionWeight = 10; //…
0
votes
1 answer

Serialize Newtonsoft.Json.Linq.JObject in C# to byte[]

In C# application, I receive binary data at some point, which are serialized to JObject with structure { "0": 255, "1": 216, "2": 255, "3": 224, "4": 0, "5": 16, . . . "12345" : 255 } , so it's always {"index" : value}. EDIT: the json…
Honza
  • 59
  • 9