Hi Developers,
I would like to debug client side applications by manually creating a JSON data stream. I was hoping that Google Chrome's debug console would be able to do this.
For example, consider the following case. I want to test how a list population code segment would work. Let's say I have item objects of the format: {"name" : "test", "price" : "10"}. Instead of actually coding this up on the server, I would like to generate this data locally and send it for testing purposes.
The Javascript would look something like this:
//JQuery AJAX call to request data
$.getJSON('some_url', function(data) {
//Go through each received JSON element (assuming array input) and
//log its key value pair to the debug console (using Google Chrome as example)
$.each(data, function(key, val) {
console.log("Key is: " + key + " value is: " + value);
}
});//End getJSON
I would want to make a list of data (perhaps in a text file?) like so:
{"name" : "paper", "price" : "5"}
{"name" : "bear repellent", "price" : "10"}
I would then like to pass this data into the function to see if it works and see the output (accomplished here by the console.log() call). I understand that this is somewhat like unit testing, and my research indicates that this might be the job for a REST client. However, I am unsure how to accomplish this. Input is appreciated.
AVADHESH PATEL
20-Jun-2013