get JSONS from a single string

i get a single String value as

"{"Link":"","DefaultValue":"","Content":"LONDON"}, {"Link":"","DefaultValue":"","Content":"United Kingdom"}"

which contains two jsons . how can i get each json and put in into an array or something in javascript/jquery ?

Please suggest the best way.


The String that you posted isn't valid JSON format. If it is an array of two objects, it should read:

'[{"Link":"","DefaultValue":"","Content":"LONDON"}, {"Link":"","DefaultValue":"","Content":"United Kingdom"}]'

Note the single quotes at the beginning and end, so that Javascript doesn't confuse the double quotes in the JSON and can parse them correctly.

Also note the brackets [] around the whole thing, that tells the parser that it is an array of objects.

You can read the new string into an object array like this:

var str = '[{"Link":"","DefaultValue":"","Content":"LONDON"}, {"Link":"","DefaultValue":"","Content":"United Kingdom"}]';
var arr = JSON.parse(str);

Need Your Help

Is there such thing as a CCK which works outside of Drupal?

php drupal open-source cck

I like the idea of the Content Construction Kit module for Drupal. Obviously it is an immensely complex Drupal module and I recognise that, so this isn't just hoping I can plug in a class to my CMS...

CSS overflow:hidden with floats

css overflow

I read the following code on w3schools and do not understand how the overflow property would impact whether text appears to the right of the "ul" or not.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.