powered by Authenteo

JSPON

JavaScript Persistent Object Notation

JSPON Core Spec

The following four JSPON fields defined (id, ready, array ) are the core JSPON fields.  They are the foundational fields for describing and transferring basic persistent objects.

id and $ref Field

In order to identify JSON objects, an id field should be set to associate an "id" with the object. By identifying an object, it can now be referenced by id. The id field should be a string. For example:

            {"id" : "34",
"myField" : "value"
"myChild": {"$ref" : "23"}
}
          

This JSON object has a two properties, and it now should be associated with identification of "34". The "myChild" member points to the object identified by the id of "23".  The object identified as "23" may or may not be described yet through JSPON communication.  This message may be referencing an object already defined as the object identified as "23", or the receptor may not have a definition for "23", but may request the object identified as "23".

Basic JSON does not support object referencing.  Therefore the following object "obj" could not be serialized with JSON:

            var obj={};
var obj2 = {"foo": "val", "bar" : 4};
obj.field1 = obj2;
obj.field2 = obj2;
          

With JSON there is no way to communicate the fact that both field1 and field2 point to the same object. The best JSON could do is to make a copy of the serialization of obj2 for each field, but this does not effectively communicate that it is the same object and if you set obj.field1.foo = "newValue", that obj.field2.foo should return "newValue".  With JSPON this referenced can be communicated:

            var obj={"id": "1", 
        "field1": {"id": "2", "foo": "val", "bar": 4},
        "field2": {"$ref": "2"}}
          

This defines the object that is targeted by field1 as the same object as targeted by field2.

Every id is implicitly a URL for an object, and follows the standard rules for relative URLs . Therefore an id can be a full URL, or the full URL can be implied by a URL used to access an object using the same rules of relative paths that are used within a browser. An object graph can span domains by using ids with fully qualified URLs refering to objects from other sites. For example:

            var obj={"id": "1", 
            

"field1": {"$ref": http://www.jspon.org/dyna/82509 )}

In this case the object has a field that references an object from another domain.

$ref can also reference fields by path as well.

Date values

JSPON defines data serialization to use ISO standard date time format with UTC timezone with a Z suffix. JSPON readers should detect strings that follow this format and convert them to Data objects.

 

Reserved Field Collision Proposal (experimental)

If the object is actually intended to have a field with the same name as a JSPON field, you can utilize explicit namespacing.  JSPON considers the JSPON fields and the normal fields to be "open" namespaces, with JSPON fields having precedence. Normal fields are considered to default to being in the public namespace. Therefore if you want to have a field called "id", you can refer to as "public::id", or if you want a field called "public::foo", it should be a JSPON field "public::public::foo".