Skip to main content

All Questions

Tagged with
3 votes
1 answer
87 views

How Can I Ignore One Property based on JsonProperty Value of another Property during Deserialization?

I have the following class, how can I ignore the Response, if StatusCode == 400? If StatusCode is 400, Response is returned in a different format that doesn't match my APIResponse class and throws an ...
CSharpData's user avatar
1 vote
1 answer
85 views

How to split big JSON schema file into multiple files to use with Newtonsoft JSON.Net

I need to write a JSON schema file for some request/response structures of an API-project, so that I can use them with "Json.NET Schema". Because some of the objects are used in mutiple ...
Michael Hartmann's user avatar
-2 votes
1 answer
81 views

Change values in JSON file

I have a JSON file with nested values, I want to change any value in the file (ex: "supplierIdentifier" value is "002264HAM001" want to replace it to "0194711AMM00". ...
Taoufik Chaieb's user avatar
1 vote
1 answer
103 views

Problem with serializing object structure with Newtonsoft Json.NET

I have to serialize a data structure for a 3rd-party interface either to XML or to JSON. The expected result should look like the following (simplified) example: XML: <?xml version=\"1.0\"...
Michael Hartmann's user avatar
2 votes
1 answer
86 views

Update table according with JSON/JSONB

I have a table books : Name of column Type id int (PK) name text nb_pages int And a table book_modifications : Name of column Type id int (PK) old_data jsonb new_data jsonb book_id int (FK) Now let's ...
Thomas's user avatar
  • 83
-1 votes
1 answer
67 views

Unexpected end of string while parsing json [duplicate]

I have the following json string: { "tables": [ "%USER%.ABCDE_FAC_FINAL_%YEAR%", "%USER%.ABCDE_FAC_STAGE_%YEAR%", "%USER%....
Mark Ainsworth's user avatar
1 vote
1 answer
41 views

Given an object graph composed of sub-classed of types which, how can we serialize that object to JSON while ignoring certain members of some types?

Given a C# object graph composed of subclasses of types which we cannot modify directly, what is the best strategy to serialize that object to JSON in .NET 4.6.2 while ignoring certain members of some ...
Brian Sweeney's user avatar
1 vote
1 answer
114 views

How to create a custom Json.NET converter to return a Json string that contains Json stored in the object being serialized

I have a C# class called MergeResponse that contains 3 properties: MessageID ApiResponse1 ApiResponse2 ApiResponse1 contains a class object instance that was created by Deserializing Json returned ...
m_collard's user avatar
  • 2,028
0 votes
1 answer
70 views

JsonConvert.DeserializeObject<T> always returns T, how to deserialize json as T only if it is T?

I was suprised, that any valid json, even empty "{ }" can be deserialized by JsonConvert.DeserializeObject as any T class. The missing values will simply be default. To example, I can't do ...
Sinatr's user avatar
  • 22.2k
0 votes
0 answers
107 views

Convert Newtonsoft JObject to System.Text.Json JsonObject

I am trying to upgrade my solution from using Newtonsoft to System.Text.Json. One of the nuget packages that I can consume calls REST APIs which return complex objects that it deserializes using ...
debracey's user avatar
  • 6,617
0 votes
0 answers
32 views

Load deep nested schema using JSchema

I have a huge JSON schema with a part of it looking like this: { "if":{ "required":[ "product_category" ], "properties":{ ...
MaciekB's user avatar
  • 61
-1 votes
2 answers
59 views

Deserialising json with JSON.NET , unable to find the right class format [duplicate]

I receive a Json file. Now the other company change the Json and I have to find the right format for my class in C.Net and I'm not able to do so. My Json looks like : { {"xxx": [ "...
baronming's user avatar
  • 258
0 votes
1 answer
78 views

Getting default values using TypeNameHandling in Newtonsoft JSON

I'm doing a basic serialize / deserialize with $type included to implement the outbox pattern. however I'm getting the default values. Here's the code serializing : JsonConvert.SerializeObject(...
Sulabee's user avatar
  • 23
1 vote
0 answers
134 views

How to read a JSON file using StreamReader in C# and skip invalid nodes

I am trying to read and process a large JSON file in C# using StreamReader and JsonTextReader. My goal is to read the JSON file node by node, and if any node contains invalid data (e.g., malformed ...
Savan Gangani's user avatar
0 votes
2 answers
68 views

Deserialize json object as a string [closed]

I have a class A that has a field string data. I perform a server request that gets me a json text that I convert to A: var a = JsonConvert.DeserializeObject<A>(jsonResponse); The problem is ...
Daniel's user avatar
  • 7,760

15 30 50 per page
1
2 3 4 5
492