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

Lifetime issue while implementing a trait for a generic type which implements a trait with an associated lifetime

I am writing a deserializer (Vec (Raw JSON) to any type T) for a project and trying to use serde for it. Here's my trait which I to decode the data: pub trait Decode: Sized { fn try_decode(input: Vec) -> Result
metamemelord
  • 500
  • 1
  • 7
  • 19
0
votes
0 answers

Json deserialization and decoding

I get external json data and want to deserialize to my collection: var responseString = await response.Content.ReadAsStringAsync(); var result = JsonParse.ParseArrayCamelCase>(responseString,…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
0
votes
1 answer

Поменялась структура ответа. W/System.err: java.lang.NullPointerException

The application was working, but then something changed in the structure of the response and during authorization (login + universal token) is not included in the application code: suspend fun authorize(phone: String, password: String) :…
Rudione
  • 1
  • 1
0
votes
1 answer

"deserializeJson() failed: NoMemory" Error with my NodeMcu-Mx with ESP8266

Im making a little project with my NodeMCU Mx with ESP8266, but ArduinoJson lib tells me there's an error. I just want to fetch the data inside my json file and use the data as variable, in order to print it on a LCD display. It was working at the…
0
votes
1 answer

I have serialized nested objects with JSON, how do I deserialize them?

I keep getting "Additional text encountered after finished reading JSON content" when deserializing. I've tried placing the whole "output" into square brackets, didn't work out. Full error message Newtonsoft.Json.JsonReaderException: 'Error reading…
user14965594
0
votes
1 answer

How to loop through nested JSON objects in C#?

I am working on a C# project where I need to call an API and parse through the JSON response. The JSON response: { "version": "3.9.1", "data": { "obj1": { "version": "1.0.0", "id": "obj1", "name":…
0
votes
1 answer

How to deserialize the Json response and store it into List?

I'm working on a webService app for the first time. I have an http api that I am using to get the list of URLs to download Sample.xml files. I have created an object class that contains the list of urls and I am trying to DeSerialize the jsonString…
Walter
  • 79
  • 6
0
votes
1 answer

Deserializing JSON objects wrapped inside unnamed root object using Jackson

I have to work with an API that returns all objects wrapped in a unnamed root object. Something like this: { "user": { "firstname":"Tom", "lastname":"Riddle" } } Here, I am interested in deserializing the user object only. But given the…
Desmond27
  • 173
  • 1
  • 4
  • 17
0
votes
1 answer

Deserialize json to Dictionary in C# applicaiton

I have this class: public class ParseJson { private HttpClient _client; public ParseJson() { _client = new HttpClient(); } public async Task> LoadJsonAsync() { …
runnerpaul
  • 5,942
  • 8
  • 49
  • 118
0
votes
0 answers

Jackson mapper Deserialization should fail when integer value given for string type

I have a Sample class data class Sample( var proxied: Boolean, var id: String, var interval: Int, var parameters: Map, ) below is Sample JSON { "proxied": "abc", "id": 123, "interval": "test", …
0
votes
0 answers

JSON AND OR operator in csharp

I'm trying to use a JSON stream using the following code(console example): using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Net.Http; using System.Data; using System.Net; namespace…
provell
  • 1
  • 1
0
votes
1 answer

Parse dynamic valueType from API call

I am working on an 3rd party implementation to our site. The API that I am calling on code returns an unique value pair. ValueType: //code, percent, money Value: //depending on ValueType can be string, int, or object { currency: string, amount:…
darcane
  • 473
  • 3
  • 14
0
votes
0 answers

Performance: Deserializing a JSON array or Storing a Const[] with data on c#?

Im storing a huge amount of data in JSON format that needs to be committed to DB. This JSON data is being deserialized into a C# class[]. Thing is there are other seed data thats stored in a static readonly Class[] and simply being loaded/sent to…
0
votes
2 answers

Deserialize JSON only if it specifies a value for a value type property

If I have a DTO class containing value type properties, how can I idiomatically use Newtonsoft to deserialize JSON to my DTO class while ensuring that the JSON defines the value type, possibly containing the default value for the type? So far the…
twinlakes
  • 9,438
  • 6
  • 31
  • 42
0
votes
1 answer

Serializing c# collection to jquery array in the view to pass through the ajax method to controller

I have viewmodel with nested collection. I want to post that form through ajax but I cant serialize it properly. Here is my view @model ARM.Presentation.ViewModels.SecurityFormProfileViewModel @{ ViewData["Title"] =…