javascript - how to serialize object into json using c# -


i tried using

var myobject = jsonconvert.serializeobject(customer); 

but problem in customer properties

firstname , service expecting json input firstname {"firstname":"neo"}

statement jsonconvert.serializeobject(customer); gives me {"firstname":"neo"} wrong.

so how can change first letter when jsonconvert.serializeobject happened ?

or how take 1 parameter input json firstname instead if using customer object.

you can define how data need serialized. when using webapi, can define camelcasepropertynamescontractresolver (part of json.net library) formatter in register method of webapi config.

public static class webapiconfig {     public static void register(httpconfiguration config)     {         config.formatters.jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver();                 } } 

the code above webapi, nevertheless believe simular approach can solution when not using webapi.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -