Questions tagged [json-deserialization]

The act of JSON deserialization involves transforming a JSON string into a particular object, commonly an instance of a class.

Jackson utilizes varying deserializers for unique scenarios

Is it possible to utilize distinct deserializers for varying scenarios? For instance: public class Student { @JsonDeserialize(using = SomeAdeserializer.class) @JsonProperty("dob") Date dateOfBirth; } Could a different deserializer like S ...

The creation of an instance for a class that is already registered in the ObjectMapper is not possible

I am facing an issue with serializing and deserializing parent and child objects using Jackson. The problem arises when the parent object contains multiple instances of the same child object, leading to errors during deserialization. On removing the @JsonI ...

Having trouble converting JSON to an object with Newtonsoft.Json library

I have encountered an issue with deserializing a sample JSON received from a service using C#. { "columns": [ "empid", "employeename", "currentAllocation", "Dept head", ...

The Web API encountered an error while trying to serialize the response body for the specified content type

Working on an ASP.NET MVC 5 Web Api project. The application already has multiple APIs in place. Recently, I added a custom JsonConverter to handle date conversions based on timezone. public class CustomInfoConverter : JsonConverter { public overrid ...

Utilizing integer-based polymorphic deserialization instead of string-based approach in Jackson

Typically, when utilizing polymorphic deserialization with Jackson, I usually have a string field that corresponds to a particular class, and the implementation may look like this. @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo. ...

Guide to deserializing JSON in C# with a specific type header and a variable type body

My JSON string contains a fixed type header and a variable body as shown below: [DataContract] public class ServiceResponseHeader { [DataMember] public string ErrorCode { get; set; } [DataMember] public string Message { get; set; } } [Da ...

Is there a way to directly override Gson's predefined number converters without using delegation?

Currently, I am facing an issue with Gson while converting my JSON data to a Map. The problem arises when Gson parses integer fields as doubles instead of longs. Is there a way to make Gson parse them correctly as longs or integers without ...

What causes a TDictionary to malfunction after deserialization?

My attempt to serialize and deserialize a standard Delphi container using the standard Delphi serializer has encountered some issues. procedure TForm7.TestButtonClick(Sender: TObject); var dict: TDictionary<Integer, Integer>; jsonValue: TJSO ...

Struggling with parsing a JSON array of objects?

{ "-6M7BoTyaAplYy120JAi": { "Address": "sample", "ID": "sample", "Name": "sample", "PhoneNumber": "sample" }, "-6M7Bp ...

Using a custom JsonConverter, learn the steps to deserialize a specific child object in Json.NET

Deserializing JSON from a web response is my goal. Here's an example of a typical response: { "response": { "garbage": 0, "details": [ { "id": "123456789" } ] } } The current format ...

Error encountered while parsing JSON file: 'additional text' is causing a syntax issue

I am attempting to retrieve data from a JSON file on an Arduino board using MATLAB with the script below: fileName = 'test1.json'; % specify the filename with a JSON extension str = fileread(fileName); % read the file as text data = ...

Transform JSON data into a Dictionary with strings as keys and lists of strings as values

As a beginner in JSON, I may have overlooked some key aspects. My goal is to Deserialize JSON data structured like below: { "Size": { "Creature": { "Dragon": [ "Huge", "Colossal", "Mountain-sized" ] ...

Create a LINQ query that retrieves records based on a specified condition

I am struggling to create a Linq query that will retrieve all records from an index file based on specific conditions. The query is getting stuck at a certain line and not progressing further. Can someone assist me in modifying the query so that only the i ...

Instructions on setting up a Newtonsoft JSON converter to convert a sophisticated data structure into a more straightforward format

I am interested in implementing the Enumerations library found at https://github.com/HeadspringLabs/Enumeration. Currently, when attempting to serialize/deserialize an Enumeration, it is serialized as a complex object. For instance, taking the example of t ...

What could be causing UserAuthExtensions.PopulateFromMap(session, jwtPayload) to fail in properly deserializing escaped JSON values within ServiceStack.Auth?

Our goal is to extract the UserName from the ServiceStack session, but we're encountering an issue with the deserialization of backslashes in the UserName. The UserName follows this format 'domainname\username', and when serialized in a ...

decipher intricate JSON data

After converting a JSON object from a YAML file, I attempted to serialize it but encountered errors. {'info': {'city': 'Southampton', 'dates': [datetime.date(2005, 6, 13)], 'gender': 'male', ...

The JSON deserialization results in a null value being returned

When sending a JSON object with AJAX formData to my Controller, I am facing an issue where it always returns null when trying to deserialize it to an object. While I can convert it to dynamic, I struggle to convert the dynamic type to the Category class. ...

Is there a way to utilize JSON.NET to deserialize a collection of JSON objects into an array?

The terms "array" and "objects" might not be exact, but you catch my drift. Looking at the sample for serializing/deserializing a custom object from the official documentation: product.Name = "Apple"; product.ExpiryDate = new DateTime(2008, 12, 28); p ...

Utilizing a Spring Kafka listener to consume JSON data and automatically determine the corresponding domain object

I have a project where I need to process various types of JSON messages that will be published. Unfortunately, I cannot modify the publisher's code to include any headers. However, I am interested in utilizing @KafkaHandler to manage these different J ...

In C#, using system.text.json to deserialize an object of a "unique" type into an array of a single class

My JSON data contains multiple objects structured like this: "SeasonalInfoBySeasonID": { "aa8e0d2d-d29d-4c03-84f0-b0bda96a9fe1": { "ID": "aa8e0d2d-d29d-4c03-84f0-b0bda96a9fe1", " ...

Getting a string array from a JSON object within the deserialize method

I am working with a JSON object that looks like this: { "name": "John", "age": 29, "bestFriends": [ "Stan", "Nick", "Alex" ] } In my code, I have created a custom implementation of JsonDeserializer: public class CustomDeserializer im ...

Using JSON in C# for dynamic serialization and deserialization operations

I am currently exploring the concept of dynamically serializing and deserializing JSON objects, as opposed to programmatically. As a Software Engineering student, I am delving into JSON and have developed a class for serialization and deserialization purpo ...

Guide to Deserializing a JSON Object in Windows Phone 8.1

Can anyone help me with an issue I'm facing? When I deserialize a JSON object and bind it to my properties, the properties show null values. Here is my code: string s = "{\"response\":{\"status\":\"fail\",\"content& ...

Is it possible to deserialize the data {"number1":5L,"number2":5L} into a class with long data fields?

After I convert the JSON: {"number1":5L,"number2":5L} to a class with long fields, I encounter the following issue: JsonParseException: Unexpected character ('L' ): was expecting comma to separate Object entries Is there a solution to res ...

Experiencing receiving a null value for an XML-formatted string following the process of

I am new to android development and I am currently working on a project where I need to call a webservice that returns a JSON string as a response. This JSON string contains an XML formatted string as one of the entries. String jsoncontent=restTemplate.ge ...

Unable to convert XML string using Newtonsoft.Json.JsonConvert.DeserializeObject

Greetings! I have a scenario where I am passing an XML as a string <AbcDto xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Abc"> <Id>2</Id> <Description>sample string 4</Des ...

Is it possible for JSON deserialization to fail within a Controller action, yet succeed when performed explicitly?

Seeking clarification on a matter that has puzzled me. While my controller actions usually handle JSON deserialization to C# objects smoothly, there is currently an issue I am grappling with. Instead of producing the expected outcome, it presents a QBWebho ...

Unpacking JSON in C#

Having trouble deserializing JSON in C# and receiving a NullReferenceException without understanding why. Here is the specific JSON being parsed: {"Entries": {"Entry": {"day": "28","month": "10","year": "1955","type": "birthday","title": "Bill Gates was ...

Error encountered while deserializing with Newtonsoft.Json JsonConvert

I successfully serialized a complex object using Newtonsoft.Jsonconverter's SerializeObject method. However, when I tried to deserialize the same object with the DeserializeObject method, I encountered the error message: "An item with this key has already ...

Unlocking the power of JSON deserialization for child objects in ASP.NET Core

Looking to deserialize a JSON API response and needing guidance on accessing properties of a nested object. Here is an example of the API response I am trying to work with: { "token_type": "Bearer", "expires_at": 1598830199, "expires_in": ...

Tips on extracting only abstract JSON data from an API response?

Description I'm attempting to send a request to an API using PHP cURL $access_token = $tokens['access_token']; $headers = array( "Authorization: Bearer " . $access_token ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,env('USER_INFO')); curl_seto ...