C# JSON Get specific attribute with multiple roots -




so basically, building c# application retrieve specific values url. url url scrape

the attributes need grab are: 'id', 'size', 'instock' , 'ats' each different size of product.

example

i have tried code this url no luck.

string data = client.downloadstring(region).replace("\n", "").replace("\r", "").replace(@"\", "").replace("\t", ""); dynamic dynobj = jsonconvert.deserializeobject(data); var somevar1 = dynobj["variants"]["by1910_530"][1]["id"].tostring(); messagebox.show(somevar1); 

please try (as using jsonconvert, assume you've got newtonsoft.json nuget package):

var client = new httpclient(); string json = await client.getstringasync(@"http://www.adidas.co.uk/on/demandware.store/sites-adidas-gb-site/uk_uk/product-getvariants?pid=by191"); var jobj = jobject.parse(json); console.writeline(jobj["variations"]["variants"][1]["id"].tostring()); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -