Version 1.7Using glow.data
API Quick Reference
JavaScript is required to use the quick reference
Overview
Glow.net.data
allows you to convert one data type to another. Below is an example that allows you to convert JSON and URL querystrings into one another.
Type in a JSON object into the left textarea, then click on one the button 'JSON to URL' to convert the object to a URL.
Here is the example code:
HTML
<textarea id="json"></textarea>
<input type="button" id="json_to_url" value="JSON to URL >" rows="10" cols="20" />
<input type="button" id="url_to_json" value="< URL to JSON" rows="10" cols="20" />
<textarea id="url"></textarea>
JavaScript
// json to url
glow.events.addListener("input#json_to_url", "click", function(event) {
try {
// Get the JSON
var json = glow.data.decodeJson(glow.dom.get("textarea#json").val());
// Encode to URL
var url = glow.data.encodeUrl(json);
// Output the encoded URL
glow.dom.get("textarea#url").val(url);
}
catch(e) {
glow.dom.get("textarea#url").val("The JSON was not properly formatted");
}
});
// url to json
glow.events.addListener("input#url_to_json", "click", function(event) {
try {
// Get the URL
var url = glow.data.decodeUrl(glow.dom.get("textarea#url").val());
// Encode To JSON
var json = glow.data.encodeJson(url);
// Output the encoded JSON
glow.dom.get("textarea#json").val(json);
}
catch(e) {
glow.dom.get("textarea#json").val("The URL was not properly formatted");
}
});