c# - How to deserialize this json to a list of objects? -


i got json msg (don't pay attention encoding) :

{ "u1000 r2v": {     "carac1": ["câble d'alimentation rigide rond"],     "optionvj": ["oui"],     "carac4": [""],     "carac3": ["pour alimentation de ligne électrique", "pour alimentation des moteurs"] }, "h05 vvf": {     "carac1": ["câble souple rond"],     "optionvj": ["oui"],     "carac4": [""],     "carac3": ["pour câblage des sélecteurs à clé", "pour alimentation des lampe clignotantes"] } } 

i've tried objects :

public class typeproductlist {     public list<producttypedto> cables { get; set; } }   public class producttypedto {     public string[] carac1;     public string[] optionvj;     public string[] carac4;     public string[] carac3; } 

but doesn't work, don't know how because "parent element" (i mean u1000 r2v, h05 vvf) changing every object. structure should use deserialize list of producttypedto? thx

as anton noted in comment, should deserialize dictionary<string, producttypedto> first.

code (uses json.net):

var result = jsonconvert.deserializeobject<dictionary<string, producttypedto>>(json); var typeproductlist = new typeproductlist { cables = result.values.tolist(); } 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -