Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

JsonConvert.DeserializeObject options camelcasing c# .net

Dictionary<string, object> jo = new Dictionary<string, object>();
jo.Add("CamelCase", 1);

var settings = new JsonSerializerSettings()
{
    ContractResolver = new CamelCasePropertyNamesContractResolver()
};

var serialized = JsonConvert.SerializeObject(jo, settings);

Assert.AreEqual("{"camelCase":1}", serialized);
Comment

JsonConvert.DeserializeObject options camelcasing c# .net

var jo = new JObject();
jo["CamelCase"] = 1;

string json = JsonConvert.SerializeObject(jo);
var jObject = JsonConvert.DeserializeObject<ExpandoObject>(json);

var settings = new JsonSerializerSettings()
{
    ContractResolver = new CamelCasePropertyNamesContractResolver()
};

var serialized = JsonConvert.SerializeObject(jObject, settings);

Assert.AreEqual("{"camelCase":1}", serialized);
Comment

PREVIOUS NEXT
Code Example
Csharp :: get domain name from email in asp.net c# 
Csharp :: C# trim trailing zero 
Csharp :: c# arrow 
Csharp :: get device name c# console 
Csharp :: unity get prefabs from folder 
Csharp :: tostring format 2 decimals 
Csharp :: exception handling in c# web api 
Csharp :: c# delete files 
Csharp :: c# winscp upload file 
Csharp :: Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output 
Csharp :: unity rigidbody2d disable 
Csharp :: mysqldump - date 
Csharp :: delay activity in uipath 
Csharp :: enum in c# 
Csharp :: searching for keys in the registry 
Csharp :: Disable Debug.log Unity 
Csharp :: remove duplicates in the list using linq 
Csharp :: jagged array to 2d array c# 
Csharp :: drop down list razor example 
Csharp :: unity get audio clip length 
Csharp :: select specific columns from datatable in c# using lambda 
Csharp :: itext7 pdfwriter outputstream c# 
Csharp :: c sharp convert string time into 24 hours time 
Csharp :: how to generate random unique id in c# 
Csharp :: get all properties of an object including children c# 
Csharp :: GetComponent<Button().onClick 
Csharp :: access label from another class c# 
Csharp :: Unlit shader get the direction of camera UNity 
Csharp :: c# mock ref parameter 
Csharp :: how to set the current user httpcontext.current.user asp.net -mvc 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =