Hazaar\View\Widgets
JSONObject
A JSON encodable object.

When rendered this object will output a string of JSON code that can be used by any client-side JavaScript code. It supports all data types including arrays, objects, strings, numbers as well as functions.

Summary
MethodsPropertiesConstants
No constants
Properties
$properties
$properties
Methods
__construct()
__construct($properties = Array ( ) )

JSON Object Constructor

add()
add($key, $items) : Hazaar\\Widgets\\JSONObject

Add an item to a property array.

count()
count() : int

Returns the number of properties currently set.

encode()
encode($items, $properties_only = false) : string

Encodes an item or an array of items into an object or array depending on whether the source array is an associative array or numeric array.

encodeItem()
encodeItem($item) : string

Encode a single item into it's JSON representation. Supported argument types are: int, float, bool, ViewableObject, null and strings. ViewableObject objects will be rendered (by calling their render() method) and their output used as is.

get()
get($key, $encoded = false) : mixed

Get and existing property. If the property doesn't exist, null will be returned.

properties()
properties() : array

Returns an array of properties currently set.

renderObject()
renderObject() : string

Render the object into encoded JSON output.

renderProperties()
renderProperties($items = null)
set()
set($key, $value, $type = null) : Hazaar\\Widgets\\JSONObject

Set a single property

setFunction()
setFunction($key, $code, $argdef = Array ( ) ) : Hazaar\\Widgets\\JSONObject

Add a JavaScript function to the list of properties. If the $code argument is just a string it will be converted to a JavaScript object.