How to convert a json object to a string in a alert box? [closed]-Collection of common programming errors

You will get the clear answer, if you provide the JSON structure.

For example, if you have below JSON structure.

  var json={ "id":23,"name":"marko"};
    for(key in json){
            alert(key+'->'+json[key]);
     }

It’s not simple for above single node json. If JSON structure is deeper, you need to iterate till you get value 🙂

Or. Rather easiest way is do console.log(json); and see in firebug, you will get what is inside json block.

Originally posted 2013-11-29 06:17:38.