Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to parse JSON with javascript?

I have an external URL for a JSON file which is hosted on another domain (not mine). Is it possible to parse this information with javascript only? Here is a sample of the JSON data. I only want to get "q" values.

[{"url":"http://website.com/?q=who+is+ip+search","q":"who is ip search"},{"url":"http://website.com/?q=eclipse+visual+editor","q":"eclipse visual editor"},{"url":"http://website.com/?q=partition+recovery","q":"partition recovery"},{"url":"http://www.website.com/?q=katzenfurz","q":"katzenfurz"},{"url":"http://website.com/?q=rtfm","q":"rtfm"},{"url":"http://website.com/?q=Google+ist+Dein+Freund","q":"Google ist Dein Freund"}]
like image 945
bammab Avatar asked Jun 27 '26 07:06

bammab


1 Answers

Browsers have native parsing methods -> JSON.parse() and JSON.stringify()

There are also several libraries that add the ability to parse JSON ...

  • http://www.json.org/js.html
  • http://developer.yahoo.com/yui/json/
  • http://api.jquery.com/jQuery.parseJSON/

Eval is sometimes used directly within JavaScript - but there are often security concerns when using this method -> http://en.wikipedia.org/wiki/JSON#JavaScript_eval.28.29

like image 149
Manse Avatar answered Jun 29 '26 20:06

Manse