JSON Content Model

The JSON Content Model is used to provide support for JSON format content. This provides a basic API to allow callers to extract values on the assumption that they know which values are to be accessed.

API

Table 1. API
Return Method Description
String getJSONAsString() Returns the JSON content as a string.
Object getObjectAt(<List of cbjecta> path, JSONArtifact artifact) throws Exception Returns the object at the specified path. The supplied root artifact may be null in which case the root of the content is used. The returned value may be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array).
Hash table (key:object, value:object> getChildValuesAt(<List of object> path, JSONArtifact artifact) throws Exception Returns the child values of the specified path if the path leads to a JSON object or null otherwise. The keys in the table are strings while the associated value may be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array).
List of objects getChildrenAt(<List of object> path path, JSONArtifact artifact) throws Exception Returns the list of objects at the specified path if the path leads to a JSON array or null otherwise. The returned values may be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array).
void reset() Flushes any internal storage associated with this content model (for example, a cached DOM object).

Nodes and outputs

This table lists nodes that build outputs which include this type of content model.

Table 2. Nodes and outputs
Node name Output name Container ID
"applykmeansas" n/a "JSON_MV"
"applyxgboosttree" n/a "JSON_MV"

Example scripts

The following scripts retrieve JSON files:


applykmeansas = stream.findByType("applykmeansas",None)
mvjson = applykmeansas.getContentModel("JSON_MV")
print(mvjson.getJSONAsString())

applyxgboosttree = stream.findByType("applyxgboosttree",None)
mvjson = applyxgboosttree.getContentModel("JSON_MV")
print(mvjson.getJSONAsString())