Created
July 3, 2012 19:12
-
-
Save leite/3042085 to your computer and use it in GitHub Desktop.
parse json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo() { | |
var json = '{"response":"","content":{"users":[{"name":"victor","age":"24"},{"name":"isabella","age":"22"},{"name":"maria","age":"12"}' + | |
',{"name":"raquel","age":"13"},{"name":"paulo","age":"22"},{"name":"isabella","age":"25"}]}}'; | |
var data; | |
var res = json.match( /{"([^"]+)":"([^"]+)","([^"]+)":"([^"]+)"}/g ); | |
for( i=0;i<res.length;i++ ) { | |
data = /{"([^"]+)":"([^"]+)","([^"]+)":"([^"]+)"}/.exec( res[i] ); | |
//console.log( data ); | |
console.log( "Nome: "+ data[2] + ", Age: " + data[4] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment