This tag can be used when you want to convert any text, objects or other formats into a JSON object,or if you want to transform a JSON object into something else.
Questions tagged [jsonconvert]
207 questions
62
votes
8 answers
how to convert json string to json object in dart flutter?
I have string like this,
{id:1, name: lorem ipsum, address: dolor set amet}
And I need to convert that string to json, how I can do it in dart flutter? thank you so much for your help.

Ashtav
- 2,586
- 7
- 28
- 44
5
votes
2 answers
Dictionary serialization for DynamoDB ExclusiveStartKey not working
For a paginated response from Dynamo, I am attempting to preserve the ExclusiveStartKey value. In the code sample, if I use the response.LastEvaluatedKey value directly, subsequent requests work fine.
However, if I serialize the…

jkh
- 3,618
- 8
- 38
- 66
5
votes
1 answer
JsonConvert.SerializeObject - Custom ContracteResolver not calling CreateProperty for multiple calls
I have a custom ContracteResolver and I am getting unpredictable results.
Using the debugger, I see that when I serialize the CreateProperty method of the resolver is called for every property. However, if I make 2 calls back to back the…

Don Chambers
- 3,798
- 9
- 33
- 74
5
votes
1 answer
Serializing a dictionary with IConvertible values using Json.NET with the TypeNameHandling-flag
I have the following dictionary that I'd very much like to serialize using Json.Net. The dictionary contains items of the IConvertible interface allowing me to add whatever primitive type I need to the dictionary.
var dic = new…

user1531921
- 1,372
- 4
- 18
- 36
4
votes
3 answers
Newtonsoft.Json works in Unity Editor but not on mobile devices
I am programming a game of questions and answers by categories in Unity. The categories are obtained through a PHP script that returns a JSON text,* when I use this solution in the UnityEditor it works correctly, but when I install the .apk on my…

Harold Alcalde Solarte
- 61
- 1
- 2
- 8
3
votes
1 answer
Get the JSON Schema's from a large OpenAPI Document OR using NewtonSoft and resolve refs
I'm currently looking extracting all of the JSON Schemas from a large OpenAPI spec. I've been using the following NuGet packages:
Microsoft.OpenApi v1.3.1
Microsoft.OpenApi.Readers v1.3.1
I was hoping to use these to parse a large Open API spec and…

JoeTomks
- 3,243
- 1
- 18
- 42
3
votes
1 answer
freezed how to assign my own JsonConverter on top level model?
I have freezed model (simplified):
part 'initial_data_model.freezed.dart';
part 'initial_data_model.g.dart';
@freezed
class InitialDataModel with _$InitialDataModel {
const factory InitialDataModel() = Data;
const factory…

Nagual
- 1,576
- 10
- 17
- 27
3
votes
2 answers
JsonConverter not working in integration tests
I've enabled my API to serialize/deserialize enum using string values. To do that I've added JsonStringEnumConverter to the list of supported JsonConverters in my API's Startup class:
.AddJsonOptions(opts =>
{
var enumConverter = new…

RiskX
- 561
- 6
- 20
3
votes
1 answer
Set Default value for missing Complex properties with JSON.net (JsonConvert.SerializeObject or JsonConvert.DeSerializeObject)
I have a requirement where I need to set default value to the below complex property Instances using JsonProperty and DefaultValue.
I know we can achieve this for primitive properties as mentioned in the below link, but need to know how we can do it…

Vinay Gangaraj
- 111
- 1
- 8
3
votes
2 answers
"Unexpected character encountered while parsing value: [." exception when deserializing into a List field
I have an object:
class Node
{
public Node(string text)
{
Text = new List { text };
}
public List Text { get; set; }
}
When I attempt to round-trip an instance of this object to JSON using Json.NET like so:
var root =…

alexania
- 2,395
- 2
- 13
- 11
3
votes
2 answers
Deserialize json to object in c# does not map values
I'm trying to deserialize a json string by using the Jsonconverter. I have all the values inside the json, I also want to mention that, that specific json is being generated from the swagger, so when i send a payload to the API it maps it into the…

Csibi Norbert
- 780
- 1
- 11
- 35
3
votes
2 answers
Converting JSON to CSV with missing fieldnames
I am having a hard time converting JSON to csv because the names on some of the records don't show up. For example:
[{device: 1,
name: 'John',
age: 25,
city: 'Denver'
},
{device: 2,
name: 'Jake',
age: 24,
city: 'New York'
},
{device:…

Jacob
- 406
- 3
- 19
3
votes
0 answers
JSONConvert.SerializeObject Maximum Length
Recently discovered that existing serialization code fails when the object to convert is too large. I know how to increase the maximum length in .NET's JavascriptSerializer. But how do I do the same thing in JsonConvert.SerializeObject?
References…

Shawn Melton
- 41
- 1
- 1
- 3
2
votes
1 answer
How can I generalize JsonConverter for all classes?
I have an entity like below:
@Entity
@Table(name = "orders")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Order {
@Convert(converter = UserInfoJsonConverter.class)
private UserInfo userInfo;
@Convert(converter =…

ElbrusGarayev
- 91
- 1
- 1
- 7
2
votes
2 answers
System.Text.Json: Convert JSON with a decimal value "NA"
I use .NET6 and Blazor. I read same data from an API. To convert the JSON I use System.Text.Json. In the JSON I expect a list of float/decimal but in same cases instead of a list of numbers there is the string "NA".
In this case, the conversion…

Enrico
- 3,592
- 6
- 45
- 102