JSON (JavaScript Object Notation) is a simple data-interchange format. Meaning it is an easy to use method to interchange data.

JSON Object

Usage:

ObjName = {Element1:Value1, Element2:Value2}

Example:

PlayerDetails = {Owner:"NEAT", Group:1}
echo "Player {PlayerDetails.Owner} is in group {PlayerDetails.Group}"

This method allows you to create and define a JSON Object and its elements. A JSON object is defined between braces {}. Within the braces you can define the elements of the objects well as the value of that element.

If you wanted to echo the above "Value" that was given to the element called "ElementName", You can do this:

The result of this would be:


json_encode

Usage:

json_encode()

Example:

JsonObj = {element:"Value"}
echo json_encode(JsonObj)

json_encode() will allow you to encode a JSON object.

If you attempted to echo a JSON Object (the object itself, not an element within) it would output this:

This is due to it being encoded in the JSON language. To be able to get valid data from the object, json_encode is needed.

Outputs:


CategoryFunctions

JSON (last edited 2015-02-08 06:36:30 by LKD70)