The examples in the first two tabs demonstrate how to load a Javascript Object via JSON at the time the page or page fragment is loaded into the browser. You can also load an object via JSON at any time as a result of an in-page event. This uses the EWD.utils.getObjectFromSession() method

Within your page you could add a button that fetches the person Session Object:

  <input type="button" id="myButton" value="Fetch Object" 
    onClick="EWD.utils.getObjectFromSession('person')">

When the button is clicked, the EWD Session Object named person will be mapped to a JSON string and instantiated into Javascript. It will be available from that point forwards.

For example:

  alert("Post code = " + person.Address.PostCode) ;

Note: you can view a Javascript Object as a JSON String using the toJsonString() method:

  alert(toJsonString(person)) ;

Note: For security reasons, you can only fetch a Session Object or Array that has been explicitly or implicitly registered as readable via JSON. You do this explicitly in a pre-page script using:

  d allowJSONAccess^zewdAPI(objectName,"r",sessid)

  eg:

  d allowJSONAccess^zewdAPI("person","r",sessid)

Note also that if you use do setJSONValue^%zewdAPI(), this will implicitly set JSON read permissions for the specified Session Object or Array

It is not possible to fetch the ewd Session Object.

Also note that once set, JSON access permissions will remain in place for an array/object throughout the user's session unless explicitly revoked using (from within a pre-page script):

  d disallowJSONAccess^zewdAPI(objectName,sessid)

  eg:

  d disallowJSONAccess^zewdAPI("person",sessid)