<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>JSON</title><revhistory><revision><revnumber>5</revnumber><date>2015-02-08 06:36:30</date><authorinitials>LKD70</authorinitials></revision><revision><revnumber>4</revnumber><date>2015-02-08 06:36:12</date><authorinitials>LKD70</authorinitials></revision><revision><revnumber>3</revnumber><date>2015-02-08 06:33:46</date><authorinitials>LKD70</authorinitials></revision><revision><revnumber>2</revnumber><date>2015-02-08 05:38:50</date><authorinitials>LKD70</authorinitials></revision><revision><revnumber>1</revnumber><date>2015-02-08 05:26:36</date><authorinitials>LKD70</authorinitials></revision></revhistory></articleinfo><para>JSON (JavaScript Object Notation) is a simple data-interchange format. Meaning it is an easy to use method to interchange data. </para><section><title>JSON Object</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>ObjName = {Element1:Value1, Element2:Value2} </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>PlayerDetails = {Owner:&quot;NEAT&quot;, Group:1}</para><para>echo &quot;Player {PlayerDetails.Owner} is in group {PlayerDetails.Group}&quot; </para></entry></row></tbody></tgroup></informaltable><para>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. </para><itemizedlist><listitem override="none"><screen><![CDATA[NameOfJSONObject = { ElementName:"Value" }]]></screen></listitem></itemizedlist><para>If you wanted to echo the above &quot;Value&quot; that was given to the element called &quot;ElementName&quot;, You can do this: </para><itemizedlist><listitem override="none"><screen><![CDATA[echo NameOfJSONObject.ElementName]]></screen></listitem></itemizedlist><para>The result of this would be: </para><itemizedlist><listitem override="none"><screen><![CDATA[ (City Name) - Value
 (City Name) - Script stopped]]></screen></listitem></itemizedlist></section><section><title>json_encode</title><informaltable><tgroup cols="2"><colspec colname="col_0"/><colspec colname="col_1"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para>Usage: </para></entry><entry colsep="1" rowsep="1"><para>json_encode() </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para>Example: </para></entry><entry colsep="1" rowsep="1"><para>JsonObj = {element:&quot;Value&quot;}</para><para>echo json_encode(JsonObj) </para></entry></row></tbody></tgroup></informaltable><para>json_encode() will allow you to encode a JSON object. </para><para>If you attempted to echo a JSON Object (the object itself, not an element within) it would output this: </para><itemizedlist><listitem override="none"><screen><![CDATA[(City Name) - [object Object]]]></screen></listitem></itemizedlist><para>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. </para><itemizedlist><listitem override="none"><screen><![CDATA[thejson = {this:"that"}
echo json_encode(thejson)]]></screen></listitem></itemizedlist><para>Outputs: </para><itemizedlist><listitem override="none"><screen><![CDATA[ (City Name) - {"this":"that"}
 (City Name) - Script stopped]]></screen></listitem></itemizedlist><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="http://guide.neatportal.com/wiki/JSON/wiki/CategoryFunctions#">CategoryFunctions</ulink> </para></section></article>