xml - Reading JSON data to C# string -
i working on c# console app project , i've been asked parse json data webpage , pull values json, such product price , colour.
my json data, pulled webpage using htmlagilitypack. had replace \" " make valid json, question, how can c# handle properly?
{ "currentasindata": { "asin": "b0013ncyx4", "buyingppu": "", "variantimages": [ { "tinyimage": { "height": "70", "url": "http: //ecx.images-amazon.com/images/i/419cbun6h8l._sl110_.jpg", "width": "110" }, "swatchimage": { "height": "19", "url": "http: //ecx.images-amazon.com/images/i/419cbun6h8l._sl30_.jpg", "width": "30" }, "mediumimage": { "height": "168", "url": "http: //ecx.images-amazon.com/images/i/419cbun6h8l._sx168_.jpg", "width": "168" }, "largeimage": { "height": "270", "url": "http: //ecx.images-amazon.com/images/i/419cbun6h8l._sx270_.jpg", "width": "270" }, "thumbnailimage": { "height": "120", "url": "http: //ecx.images-amazon.com/images/i/419cbun6h8l._sx120_.jpg", "width": "120" } } ] } } now, above json correct far know, i'm unable read data c# doesn't allow " , if use \" jarray fails deserialize object.
i'm new json in c#, using json.net library, end goal decipher json, can retrieve data c# string further usage. i'm stuck how can this.
thanking in advance!
more information requested.
my code scrape javascript json data here.
string thescript = xd.selectsinglenode(".//div[contains(@class,'webstore-productjsondata')]/script[contains(.,'var detaildata')]").getinnerxml().htmldecode(); if(thescript != null) { string[] varsln = regex.split(thescript, "var detaildata ="); string json = varsln[1].htmldecode().replace("};\nvar extensibilitydata = {};\n\r\n//]]>//", "").trim(); console.writeline(json); } the webpage taking json
http://www.dangleberrymusic.co.uk/childrens-childs-electric-guitar- quarter/dp/b00eseoxwk?class=quickview&field_availability=-1&field_browse=1592919031&id=childrens+childs+electric+guitar+quarter&ie=utf8&refinementhistory=color_map%2cbrandtextbin%2csubjectbin%2cprice%2csize_name&searchnodeid=1592919031&searchpage=1&searchrank=salesrank&searchsize=12
you can model json object , use json.net deserialize it.
asindata ad = jsonconvert.deserializeobject<asindata>(json)
Comments
Post a Comment