W3Schools Learner's Blog

w3Schools programming knowledge summary website

div

11/26/2017

how to get json object key and value | javascript tutorials

how to get json object key and value? It's simple, i will show you the way of get json key and value in javascript.
this is javascript code.
<script>
var jsonObj = {"jack":"american","xiaoming":"chinese"};
for(var key in jsonObj){
 console.log(key+"==="+jsonObj[key]);
}
</script>
output string:
jack===american
xiaoming===chinese

No comments:

Post a Comment

Note: only a member of this blog may post a comment.