Creating a json obj from a string when working without a net connection?
Posted
by user246114
on Stack Overflow
See other posts from Stack Overflow
or by user246114
Published on 2010-05-27T17:18:23Z
Indexed on
2010/05/27
17:21 UTC
Read the original article
Hit count: 134
JavaScript
Hi,
I have a json object returned from a third party api, it looks like:
{"version":"1.0","encoding":"UTF-8"}
I'm going to be working on my project without a network connection, so I have to do everything locally. How can I create an instance of a json object locally for testing? Say I copy the above string, can I do something like:
var json = null;
if (debugging_locally) {
json = new jsonObj('{"version":"1.0","encoding":"UTF-8"}');
}
else {
json = doAjaxCall();
}
doStuffWithJsonObj(json);
so I just want to create a json object from a stored string if debugging locally - how can I do that?
Thanks
© Stack Overflow or respective owner