Foundations.ObjectUtils
This namespace contains functions that operate on objects.
ObjectUtils.toQueryString()
Takes an object of name/value pairs, for example:
{'key1': 'value one', 'key2': 'value 2' }
And turns it into a string, for example:
key1=value%20one&key2=value%20two
It replaces the Prototype function Object.toQueryString.
Note:
Does not handle object arrays.
Syntax
ObjectUtils.toQueryString(obj)
Parameters
| Argument | Required | Type | Description |
| obj | Yes | any object | Object to convert to string. |
Returns
{ object string : string }
Example
var libraries = MojoLoader.require({ name: "foundations", version: "1.0" }); var ObjectUtils = libraries["foundations"].ObjectUtils; var ItemPrices = { "Item" : "drink", "price" : 2}; Mojo.Log.info("ItemPrices string = "+ ObjectUtils.toQueryString(ItemPrices));
Example Output
ItemPrices string = Item=drink&price=2