Questions tagged [jsonserializer]

The JsonSerializer enables to control how objects are encoded into JSON. JSONSerializer will also pay attention to any method or field annotated by JSON.

JSONSerializer is the main class for performing serialization of Java objects to JSON. JSONSerializer by default performs a shallow serialization. While this might seem strange there is a method to this madness. Shallow serialization allows the developer to control what is serialized out of the object graph. This helps with performance, but more importantly makes good OO possible, fixes the circular reference problem, and doesn't require boiler plate translation code.

A simple example:

JSONSerializer serializer = new JSONSerializer();
return serializer.serialize( person );

Source:

Related tags:

512 questions
-1
votes
2 answers

System.Text.Json.JsonException: The JSON value could not be converted to System.Collections.Generic.List`1[System.Collections.Generic.List`1

I'm a beginner in C# development and I need your help.. I am checking all the subject in Stackoverflow but I can't find and fix my problem. I received a JSON response from an API and I would like to transform the data in object. ------------ Here my…
-1
votes
1 answer

JSON deserialisation from a network stream in .Net 6

I have a server which I do not control. I would like to interact with it by sending JSON requests and receiving JSON responses via TCP/IP socket. Let's assume UTF8 encoding is used and I have an open TCP connection with attached NetworkStream or…
AndreyR
  • 301
  • 2
  • 10
-1
votes
2 answers

JsonResult object to JObject

I found a problem, and I am interested what would be the best solution to create from a JsonResult object a JObject. The JsonResult is created like this: Json(new { productId, gtin, mpn, sku, price, basepricepangv, …
Wasyster
  • 2,279
  • 4
  • 26
  • 58
-1
votes
2 answers

How to deserialize a nested json string?

Suppose I have this classes: internal class Test { public string value { get; set; } public Test(string value) { this.value = value; } } public class Response { private string errorMessage { get; } private T…
D4NieLDev
  • 260
  • 1
  • 3
  • 14
-1
votes
1 answer

Unhandled Exception: '_InternalLinkedHashMap' is not a subtype of type 'String?' in type cast

i am trying to fetch data " Unhandled Exception: type ''_InternalLinkedHashMap' is not a subtype of type 'String?' in type cast" i am using jsonserializable this is my data file i want to use it in product file CartModel import…
july
  • 31
  • 1
  • 1
  • 8
-1
votes
2 answers

Convert JSON object to Model in .NET

I have this JSON object returned from API: [ { "batchId": 789, "debtId": 1841, "dateAdded": "2021-07-27T16:01:39.41", "debtCategoryId": 2, "agreementNumber": 78262155, "clientNumber": 1068055, "clientName": "Client…
Laziale
  • 7,965
  • 46
  • 146
  • 262
-1
votes
1 answer

Serializing and Deserializing stream using system.text.json

I am new to using System.Text.Json. I was using BinaryFormatter, now need to migrate to System.Text.Json due to Security vulnerabilities Binaryformmater poses. I need to serialize the object into the stream and store it in disk. Then Upon calling…
Al Pa chino
  • 75
  • 2
  • 8
-1
votes
1 answer

Java : JSON Deserilization to convert the lower_case to camelCase

I am trying to convert the keys in my json string to camelCase..i have gone trough various posts in the stackoverflow but couldn't come to the solution.. i have a json string coming in the below format.. { "tech":[ { …
ram
  • 41
  • 1
  • 8
-1
votes
1 answer

how to serialize only specific value from complex type property of class using newton soft

I have a class with multiple properties where some of the properties is a complex type those it self having multiple other properties, I don't want to use JsonIgnore annotation over all those unwanted properties, looking way to get only one property…
Neeraj Kumar Gupta
  • 2,157
  • 7
  • 30
  • 58
-1
votes
1 answer

Error converting value \"1D\" to type 'System.Int64' while desalinizing JSON object to data table

I am trying to deserialize jsonoutput to the data table and getting the below error Error converting value "1D" to type 'System.Int64' I am using this - > JsonConvert.DeserializeObject(Of DataTable)(jSonOutput) Data in the input column is similar to…
Pavan Gunda
  • 57
  • 1
  • 7
-1
votes
1 answer

Can not deserialize appsettings IConfiguration section into array of typed elements

I am trying to retrieve an IConfiguration section from my appsettings.json file which is an array of strongly typed elements and i keep getting an empty collection. I am using whatever Asp .Net Core 3.1 uses by default when deserializing the…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
-1
votes
1 answer

How to save floats not in exponential notation?

JsonSerializer saves float values in JSON file in exponential notation ( like 1.774073E-05 ) How to change its settings so values are saved as regular floats, i.e. 0.0001774073 ? string text = File.ReadAllText(path, Encoding.UTF8); JObject json =…
yaru
  • 1,260
  • 1
  • 13
  • 29
-1
votes
1 answer

jObject.Parse and JsonConvert.DeserializeObject data into a DataTable resulting in Parameter Count Mismatch exception

I have trouble with the following (test) code. This gives me a "Parameter Count Mismatch" error at the line dataTable.Merge(CreateDataTableFromObject(info.GetValue(inputObject))); The entire code looks like this: public object…
-1
votes
1 answer

How do we Change PropertyName of Linq expression?

I have Linq Expression as below, which executes on DocumentDB SQL API on CosmosDB database. predicate = predicate.And(x => x.SystemID== "123"); When I execute it to the context it by default generate SQL statement like below. select * from [Table]…
-1
votes
2 answers

JSON maxJsonLength Property

I am using following code in .cshtml file. var typeVM = JSON.parse('@Html.Raw(Json.Encode(Model.typeVM))'); Shows following Error: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds…
Sameer
  • 131
  • 1
  • 9