dojox/json/ref (version 1.10)

Summary

Adds advanced JSON {de}serialization capabilities to the base json library. This enhances the capabilities of dojo.toJson and dojo.fromJson, adding referencing support, date handling, and other extra format handling. On parsing, references are resolved. When references are made to ids/objects that have been loaded yet, the loader function will be set to _loadObject to denote a lazy loading (not loaded yet) object.

See the dojox/json/ref reference documentation for more information.

Property Summary

Method Summary

  • _addProp(id,prop)
  • fromJson(str,args) evaluates the passed string-form of a JSON object.
  • resolveJson(root,args) Indexes and resolves references in the JSON object.
  • toJson(it,prettyPrint,idPrefix,indexSubObjects) Create a JSON serialization of an object.

Properties

_useRefs
Defined by: dojox/json/ref
refAttribute
Defined by: dojox/rpc/JsonRest
serializeFunctions

Methods

_addProp(id,prop)
Defined by dojox/json/ref
Parameter Type Description
id undefined
prop undefined
Returns:string
fromJson(str,args)
Defined by dojox/json/ref

evaluates the passed string-form of a JSON object.

Parameter Type Description
str String

a string literal of a JSON item, for instance:

'{ "foo": [ "bar", 1, { "baz": "thud" } ] }'
args Object
Optional

See resolveJson

Returns:any | undefined

An object, the result of the evaluation

resolveJson(root,args)
Defined by dojox/json/ref

Indexes and resolves references in the JSON object.

A JSON Schema object that can be used to advise the handling of the JSON (defining ids, date properties, urls, etc)

Parameter Type Description
root Object

The root object of the object graph to be processed

args Object
Optional

Object with additional arguments:

  • The index parameter: This is the index object (map) to use to store an index of all the objects. If you are using inter-message referencing, you must provide the same object for each call.
  • The defaultId parameter: This is the default id to use for the root object (if it doesn't define it's own id)
  • The idPrefix parameter: This the prefix to use for the ids as they enter the index. This allows multiple tables to use ids (that might otherwise collide) that enter the same global index. idPrefix should be in the form "/Service/". For example, if the idPrefix is "/Table/", and object is encountered {id:"4",...}, this would go in the index as "/Table/4".
  • The idAttribute parameter: This indicates what property is the identity property. This defaults to "id"
  • The assignAbsoluteIds parameter: This indicates that the resolveJson should assign absolute ids (__id) as the objects are being parsed.
  • The schemas parameter: This provides a map of schemas, from which prototypes can be retrieved
  • The loader parameter: This is a function that is called added to the reference objects that can't be resolved (lazy objects)
Returns:any | undefined

An object, the result of the processing

toJson(it,prettyPrint,idPrefix,indexSubObjects)
Defined by dojox/json/ref

Create a JSON serialization of an object. This has support for referencing, including circular references, duplicate references, and out-of-message references id and path-based referencing is supported as well and is based on http://www.json.com/2007/10/19/json-referencing-proposal-and-library/.

Parameter Type Description
it Object

an object to be serialized.

prettyPrint Boolean
Optional

if true, we indent objects and arrays to make the output prettier. The variable dojo.toJsonIndentStr is used as the indent string -- to use something other than the default (tab), change that variable before calling dojo.toJson().

idPrefix Object
Optional

The prefix that has been used for the absolute ids

indexSubObjects Object
Optional
Returns:any | undefined

a String representing the serialized version of the passed object.

Error in the documentation? Can’t find what you are looking for? Let us know!