Parsing json string for multiple stock quotes -


this data returned request "jnj" , "adp" stock information.

var quote = new object();      quote['jnj'] = {     ticker: 'jnj',      valoren: 943981,      exchangecode: 321,      exchange: 'ny',      exchangename: 'new york stock exchange',      exchangeshortname: 'nyse',      tradetime: 1375906505,     volume: 9052146,      last: 93.66,      open: 93.60,      high: 94.03,      low: 93.47,     prevclose: 93.81,      change: -0.15,      changepercent: -0.1599,      bid: 93.66,     ask: 93.68,      bidsize: 2500,      asksize: 800,      name: 'johnson & johnson',     shortname: 'johnson',      isin: 'us4781601046',      sharesoutstanding: 2818073863 };  quote['adp'] = {     ticker: 'adp',      valoren: 910042,     exchangecode: 537,      exchange: 'nq',      exchangename: 'nasdaq stock market',      exchangeshortname: 'nasdaq',      tradetime: 1375905600,      volume: 1460941,      last: 71.99,      open: 72.11,      high: 72.28,      low: 71.67,      prevclose: 72.24,      change: -0.25,      changepercent: -0.3461,      bid: 71.99,      ask: 72.00,      bidsize: 9300,      asksize: 300,      name: 'automatic data processing',     shortname: 'automatic data',      isin: 'us0530151036',      sharesoutstanding: 485222417 };  eval('updatequotes(quote)'); 

i novice @ this. have tried json.net continue errors. appears not proper json. thought maybe stripping of before "{" , after "}" may work, far no luck. or ideas appreciated.

edit: limiting single stock, stripping off before "{" , after "}", can parse fine using:

string input = json; var jss = new javascriptserializer(); dictionary<string, string> sdata = jss.deserialize<dictionary<string, string>>(json); string _ticker = sdata["ticker"].tostring(); string _last = sdata["last"].tostring(); console.writeline(_ticker + "  " + _last); 

try removing last eval('updatequotes(quote)') check object deserializing of format

public class rootobject {  public string ticker { get; set; } public int valoren { get; set; } public int exchangecode { get; set; } public string exchange { get; set; } public string exchangename { get; set; } public string exchangeshortname { get; set; } public int tradetime { get; set; } public int volume { get; set; } public double last { get; set; } public double open { get; set; } public double high { get; set; } public double low { get; set; } public double prevclose { get; set; } public double change { get; set; } public double changepercent { get; set; } public double bid { get; set; } public double ask { get; set; } public int bidsize { get; set; } public int asksize { get; set; } public string name { get; set; } public string shortname { get; set; } public string isin { get; set; } public int sharesoutstanding { get; set; } } 

you can verify json string c# object using http://json2csharp.com/


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -