• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "JSON"
    Differences between revisions 1 and 2
    Revision 1 as of 2015-02-08 05:26:36
    Size: 1495
    Editor: LKD70
    Comment:
    Revision 2 as of 2015-02-08 05:38:50
    Size: 2688
    Editor: LKD70
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 6: Line 6:
    ||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start; " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!ObjName = {Element1:Value1, Element2:Value2} ||
    ||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!PlayerDetails = {Owner:"NEAT", Group:1}<<BR>>echo "Player {!PlayerDetails.Owner} is in group {!PlayerDetails.Group}" ||
    ||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start;     " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;     ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!ObjName = {Element1:Value1, Element2:Value2} ||
    ||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;     ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!PlayerDetails = {Owner:"NEAT", Group:1}<<BR>>echo "Player {!PlayerDetails.Owner} is in group {!PlayerDetails.Group}" ||
    Line 9: Line 9:
    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.

    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.
    Line 14: Line 15:
    Line 15: Line 17:
    Line 18: Line 21:
    Line 19: Line 23:
    Line 24: Line 29:
    <<BR>>

    == json_encode ==
    ||<tablebgcolor="#F9F9F9" tablestyle="margin:1em 1em 1em 0px;border-style:solid;border-color:rgb(170, 170, 170);color:rgb(0, 0, 0);font-family:sans-serif;font-size:13px;line-height:19.5px;text-align:start; " tableclass="wikitable"#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Usage: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">json_encode() ||
    ||<#F2F2F2 style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em; ">Example: ||<style="border-style:solid;border-color:rgb(170, 170, 170);padding:0.2em;">!JsonObj = {element:"Value"}<<BR>>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:
     . {{{
    (City Name) - [object Object]
    }}}
    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.
     .{{{
    thejson = {this:"that"}
    echo json_encode(thejson)
    }}}
    Outputs:
     .{{{
     (City Name) - {"this":"that"}
     (City Name) - Script stopped

    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.

    • NameOfJSONObject = { ElementName:"Value" }

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

    • echo NameOfJSONObject.ElementName

    The result of this would be:

    •  (City Name) - Value
       (City Name) - Script stopped


    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:

    • (City Name) - [object Object]

    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.

    • thejson = {this:"that"}
      echo json_encode(thejson)

    Outputs:

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