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
1
vote
2 answers
Json serialization in JavaScriptSerializer C#
I have object in my app in c# i need to serialize it to JSON but I need to custom the result json to be like below :
My class :
public class OrderStatus
{
public string title { get; set; }
public int statusNo { get; set; }
…

Mohamed Moqbel
- 57
- 1
- 5
1
vote
1 answer
Multidimensional ArrayList in flutter convert to model class
I am using WordPress Api's for my flutter application.
I have model class(POJO) in which there is ArrayList inside another arrayList.I don't know how to convert it to model class. Please Help.
The Json is:
wp:term: [
[
{
id: 22,
link:…

Sunil
- 143
- 1
- 2
- 11
1
vote
2 answers
Convert JSON to C# Object array
This is my JSON object and C# class
{
"header": [
"id",
"name",
"address"
],
"rows": [
[
"ee1e9edd-a06b-3f8c-97f1-62878d04540d",
"John Doe",
…

Zulqarnain Jalil
- 1,679
- 16
- 26
1
vote
1 answer
Member class not serializing the defined way
How to make sure that custom class that's inside another class gets serialized as it's defined?
I have a class:
public class Event
{
public string Type { get; set; }
public DateTime Timestamp { get; set; }
public override string…

Alcibiades
- 335
- 5
- 16
1
vote
1 answer
Is there a way to access customParameters object[] from within a custom JsonConverter class implementation?
I wrote a custom JsonConverter called CompententsConverter and it works fine, however I'm curious if there is a way to make use of the alternate constructor which takes params object[] converterParameters and pass over my own custom parameters from…

MetaGuru
- 42,847
- 67
- 188
- 294
1
vote
1 answer
How to Serialize Dictionary to json using JsonConvert newtonsoft c#
Trying to serialize Dictionary
var requestData = new Dictionary
{
{ "games" ,new Dictionary { {new string[] { "1000"}, 1 } } }
};
var data = JsonConvert.SerializeObject(requestData);
The…

aderw
- 41
- 4
1
vote
1 answer
JsonConvert does not serialize all useful properties of an exception
I'm catching the below exception during media encoding:
catch (Microsoft.Azure.Management.Media.Models.ApiErrorException e)
{
var str1 = e.ToString();
var str2 = JsonConvert.SerializeObject(e);
}
What I have noticed is that in both strings,…

user246392
- 2,661
- 11
- 54
- 96
1
vote
1 answer
Serialization problem in a custom collection with a private list
Given two classes as follows:
class ListCollection : List
{
}
[Serializable]
class PrivateListCollection: ISerializable
{
private List list = new List();
public void Add(int value)
{
list.Add(value);
}
…

Zordex
- 53
- 1
- 5
1
vote
1 answer
How to read entire string from JsonTextReader
I have a JsonConverter. I created a unit test for the ReadJson. I have an error in my unit test that says the reader value is null. How can I read the entire string from the reader?
public class StringConverter : JsonConverter
{
public…

fereshteh rabet
- 198
- 1
- 2
- 11
1
vote
0 answers
C# JsonConverter sometimes loses reference to original instance
I'm using custom JsonConverters with RavenDB in order to write/read references when saving/retrieving. In addition, the entity I'm working on it's a nested structure that starts populating itself using these references, calling the RavenBroker…

Germán Stark
- 19
- 1
1
vote
1 answer
Deserializing a JSON Array of size 1 in c#
I have two different JSON object which differ slightly for one property:
string JSONObject1 = "
{
prop1: val1
prop2: {
prop3: val3
prop4: val4
}
}
"
string JSONObject2 = "
{
prop1: val1
prop2: [{
prop3: val3
…

CodingEveryDay
- 21
- 5
1
vote
2 answers
Using JsonConvert.DeserializeObject to dynamically choose class
So I am making an api call and I need to use JsonConvert.DeserializeObject to convert it to a class. The Json structure comes back as the following
{
"fcResponse": {
"responseData": {
"fcRequest": {
"mail":…

Xyloking17
- 83
- 1
- 5
1
vote
3 answers
How to throw an exception when member comes twice on Deserializing with JsonConvert
I have JSON which contains duplicated members:
[
{
"MyProperty": "MyProperty1",
"MyProperty": "MyWrongProperty1",
"MyProperty2": "MyProperty12",
"MyProperty2": "MyWrongProperty2"
},
{
"MyProperty": "MyProperty21",
…

Dilshod K
- 2,924
- 1
- 13
- 46
1
vote
3 answers
Why do I get "Unexpected character encountered while parsing value" when using Newtonsoft.Json.DeserializeObject with a string?
I'm getting the mentioned error when trying to DeserializeObject() into a list of strings.
ResultSet is fine and making a string as:
string sRetVal_Json = new JavaScriptSerializer().Serialize(ResultSet);
also works fine.
The resultant string,…

Gary Huckabone
- 402
- 3
- 10
1
vote
1 answer
How to convert object list json model?
I want to send a JSON model to the front as follows:
Here it is:
{
"2020-01-22":1,
"2020-01-23":2,
"2020-01-24":3,
..
}
I have data that I pulled through the database. Here is my class for the list of objects:
public class…

Muhammed Caylak
- 339
- 1
- 4
- 15