About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Last updated: Feb 11, 2025
The JSON content model is used to access content stored in JSON format. It provides a basic API to allow callers to extract values on the assumption that they know which values are to be accessed.
Method | Return types | Description |
---|---|---|
|
|
Returns the JSON content as a string. |
|
|
Returns the object at the specified path. The supplied root artifact might be null, in which case the root of the content is used. The returned value can be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array). |
|
|
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 can be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array). |
|
|
Returns the list of objects at the specified path if the path leads to a JSON array or null otherwise. The returned values can be a literal string, integer, real or boolean, or a JSON artifact (either a JSON object or a JSON array). |
|
|
Flushes any internal storage associated with this content model (for example, a cached DOM object). |
Example script
If an output builder node creates output based on JSON format, you could use the following to access information about a set of books:
results = []
outputbuilder.run(results)
output = results[0]
cm = output.getContentModel("jsonContent")
bookTitle = cm.getObjectAt(["books", "ISIN123456", "title"], None)
# Alternatively, get the book object and use it as the root
# for subsequent entries
book = cm.getObjectAt(["books", "ISIN123456"], None)
bookTitle = cm.getObjectAt(["title"], book)
# Get all child values for aspecific book
bookInfo = cm.getChildValuesAt(["books", "ISIN123456"], None)
# Get the third book entry. Assumes the top-level "books" value
# contains a JSON array which can be indexed
bookInfo = cm.getObjectAt(["books", 2], None)
# Get a list of all child entries
allBooks = cm.getChildrenAt(["books"], None)
Was the topic helpful?
0/1000