javascript - Converting json object to a string -


i'm generating json object follows, need iterate , fetch value inside in javascript.

[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object],[object object] 

and if stringify it, i'll following values,

[[{"k":"43800001","d":"resident demand deposit"},{"k":"43800099","d":"not applicable"}, {"k":"43800014","d":"cash"}, {"k":"43800012","d":"income , expenditure"}, {"k":"43800011","d":"other liabilities"}, {"k":"43800010","d":"other assets"}, {"k":"43800009","d":"bankers"}, {"k":"43800008","d":"bar"}, {"k":"43800007","d":"dd"}, {"k":"43800006","d":"ho"}, {"k":"43800005","d":"advance"}, {"k":"43800004","d":"investments"}, {"k":"43800003","d":"bills"}, {"k":"43800002","d":"resident term deposit"}]] 

there 14 record pairs contains k holding code, , d holding description of code. need iterate each k, d pair data.

i'm trying follows, reusult holding 14 [object object] value show above.

result[0].k.tostring(); result[0].d.tostring(); 

i'm getting type error.

i recomend use stringify.

example:

json.stringify({ x: 5 }) 

here in case can store entire object or array in variable , pass stringify method:

example:

var data = { x: 5 };  json.stringify(data)  

output like:

'{"x":5}' 

hoping :)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -