Class sap.ui.model.json.JSONModelModule: sap/ui/model/json/JSONModel

extends ClientModel

Model implementation for JSON format

Constructor Summary
new sap.ui.model.json.JSONModel(oData)Constructor for a new JSONModel.
Method Summary
sap.ui.model.json.JSONModel.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.json.JSONModel with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.json.JSONModel.getMetadata()Returns a metadata object for class sap.ui.model.json.JSONModel.
getJSON()Serializes the current JSON data of the model into a string.
getProperty(sPath, oContext?)Returns the value for the property with the given sPropertyName
loadData(sURL, oParameters?, bAsync?, sType?, bMerge?, bCache?, mHeaders?)Load JSON-encoded data from the server using a GET HTTP request and store the resulting JSON data in the model.
setData(oData, bMerge?)Sets the JSON encoded data to the model.
setJSON(sJSONText, bMerge?)Sets the JSON encoded string data to the model.
setProperty(sPath, oValue, oContext?, bAsyncUpdate?)Sets a new value for the given property sPropertyName in the model.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.json.JSONModel(oData)
Constructor for a new JSONModel.
Parameters:
{object}oData either the URL where to load the JSON from or a JS object
Method Detail
sap.ui.model.json.JSONModel.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.json.JSONModel with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.ClientModel.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.ui.model.json.JSONModel.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.json.JSONModel.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
getJSON(): string
Serializes the current JSON data of the model into a string. Note: May not work in Internet Explorer 8 because of lacking JSON support (works only if IE 8 mode is enabled)
Returns:
{string} sJSON the JSON data serialized as string
getProperty(sPath, oContext?)
Returns the value for the property with the given sPropertyName
Parameters:
{string}sPath the path to the property
{object}oContext? the context which will be used to retrieve the property
loadData(sURL, oParameters?, bAsync?, sType?, bMerge?, bCache?, mHeaders?)
Load JSON-encoded data from the server using a GET HTTP request and store the resulting JSON data in the model. Note: Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy, the request can not successfully retrieve data from a different domain, subdomain, or protocol.
Parameters:
{string}sURL A string containing the URL to which the request is sent.
{object|string}oParameters? A map or string that is sent to the server with the request. Data that is sent to the server is appended to the URL as a query string. If the value of the data parameter is an object (map), it is converted to a string and url-encoded before it is appended to the URL.
{boolean}bAsync?, Default: true By default, all requests are sent asynchronous (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
{string}sType?, Default: GET The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
{boolean}bMerge? whether the data should be merged instead of replaced
{string}bCache? force no caching if false. Default is false
{object}mHeaders? An object of additional header key/value pairs to send along with the request
setData(oData, bMerge?)
Sets the JSON encoded data to the model.
Parameters:
{object}oData the data to set on the model
{boolean}bMerge? whether to merge the data instead of replacing it
setJSON(sJSONText, bMerge?)
Sets the JSON encoded string data to the model.
Parameters:
{string}sJSONText the string data to set on the model
{boolean}bMerge? whether to merge the data instead of replacing it
setProperty(sPath, oValue, oContext?, bAsyncUpdate?): boolean
Sets a new value for the given property sPropertyName in the model. If the model value changed all interested parties are informed.
Parameters:
{string}sPath path of the property to set
{any}oValue value to set the property to
{object}oContext? the context which will be used to set the property
{boolean}bAsyncUpdate? whether to update other bindings dependent on this property asynchronously
Returns:
{boolean} true if the value was set correctly and false if errors occurred like the entry was not found.