c# - Parsin JSON with @ sign in key field -


i getting json follow:

        "name": {             "@value": "foo"         },         "lastname": {             "@value": "bar"         },         "birth": {             "@value": "198701010000"         } 

when try parse this, unable values 'foo', 'bar' , bday.

rootobject deserializedproduct = jsonconvert.deserializeobject<rootobject>(obj); 

i m using code above parse it.

how can parse properly?

assuming have class rootobject looks this:

public class rootobject {     public item name { get; set; }      public item lastname { get; set; }      public item birth { get; set; } } 

you can define item this:

public class item {     [jsonproperty("@value")]     public string value { get; set; } } 

and use jsonproperty attribute specify name of property you'd map item.value to.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -