Location: PHPKode > projects > Dresscode Framework > dresscode-master/applications/common/views/json-config.xml
<?xml version="1.0" encoding="utf-8" ?>

    text: true|false

    When true wraps the resulting JSON in [] array braces

    text: true|false

    Flattens simple elements, child nodes which are unique and have no attributes, into the
    parrent element.

    For example given the following xml:

        <b>New York</b>

    When flattenSimpleElements is false the resulting JSON would be:

      {node:{a:{$:'Ottawa'},b:{$:'New York'},c:{$:'London'}}}

    When flattenSimpleElements if true the resulting JSON would be:

      {node:{$a:'Ottawa',$b:'New York',$c:'London'}}

    Notice the $ since precedes the attribute name.  This is the value
    assigned to settings\elements\prefix config node.

    There is also the case of collections that are rendered in json as arrays.
    Given the following example

      <option>Great Britain</option>

    In JSON this would be rendered as
    MYSJON=[{root:{option:[{$:"Canada"},{$:"U.S."},{$:"Great Britain"}]}}]

    Given that the option elements are simple in that they have no attributes
    or children we could also render the option collection as a simple
    JavaScript Array.  This would result in the following JSON:

    MYSJON=[{root:{option:["Canada","U.S.","Great Britain"]}}]

    Of course doing so renders the array values as simple strings but they could
    easily be converted to custom objects if need be at load time.

    To enforce simple object collections to be rendered as arrays set the
    flattenSimpleCollectionsToArrays to true


    text: anything

    Under a specific circutance duplicate object properties could be assigned
    tothe same object.  Take into consideration the following XML

      <root id="1234">

    Under standard naming conventions like BadgerFish you would have the following
    JSON object

    JSON = [{root:{id:1234,id:{$:abcd}}[

    As can be seen id is duplicated.  It would not be natural in this case to move both
    ID properties into an array since the are not both datatyped the same.  In this case
    the appendforDuplicate switch can be used to append on a name to the element in order
    to reduce redundency.

    For example setting the switch to MYNODE would result in:

    JSON = [{root:{id:1234,idMYNODE:{$:abcd}}]


    text: true|false

    When true the root node it dropped from the resulting JSON. Given
    the following xml:

        <address street="a" zip="bbb123"/>

    With dropRoot false the JSON would be:


    With dropRoot true the JSON would be:


    stringValues: Encase string values in character(s), for example '
    objectNames:  Encase object names/properties in character(s), for example ' or "

    prefix:   Prepend provided string to name of attributes
    suffix:   Append provided string to name of suffix

    prefix:   Prepend provided string to name of attributes
    suffix:   Append provided string to name of suffix


  List of val elements containing from and to elements. Use this section to add in conversion
  strings you want applied to string elements/attributes

    These are string value attributes/elements that you do not want encased or prefixed or suffixed.
    In other words treat them as pointers to other javascript objects or use them to explicitly
    define the datatypes the value should be rendered to.

    The syntax for the pointer elements is
    <pointer type="[native|string|date|datetime|boolean|number]" match="[exact|any]">xpath expresssion</pointer>

    For example if you had the following xml
      <test myFunction="function(){alert('hello world')}"/>

    Create the pointer as
    <pointer type="native" match="exact">/root/test/@myFunction</pointer>

    You JSON would then have
    {root:{test:{myFunction:function(){alert('hello world')}}}}

    Note, be carefull when using match of 'any' as this may result in unexpected
    results if you have elements/attributes with similar names or paths

    <pointer type="native" match="exact">/root/note/pricing/data</pointer>
    <pointer type="string" match="any">@value</pointer>
    <pointer type="date" match="any">@dtm</pointer>


Return current item: Dresscode Framework