To add custom dynamic content, use a program object as per the example in the Programs folder of the jsonToolkit palette. Or you can extend BAbstractInlineJsonWriter. As code contained in a module is easier to maintain, extending the abstract class would be preferred where the program object
may be widely distributed.
This palette example implements a method: public BValue onOverride(final BInlineJsonWriter input), which you can customize to meet your project’s needs. The InlineJsonWriter has two important methods:
JSONWriter jsonWriter = in.getJsonWriter();BComplex base = in.getCurrentBase();Demonstrated below:
/**
* The override method allows control of the writer and current base to be passed
* to the code below * allowing JSON to be dynamically constructed within a schema.
*
* @param BInlineJsonWriter wraps two things:
* JSONWriter jsonWriter = in.getJsonWriter();
* BComplex base = in.getCurrentBase();
*
* @return BValue allows logging of the "result" when fine logging is enabled
* (this does not need to match what happened to the JSON...)
*/
public BValue onOverride(final BInlineJsonWriter in)
{
//current base is set by the parent schema as each point is submitted for publishing
BComplex base = in.getCurrentBase()
//if (base instanceof BComponent)
JSONWriter jsonWriter = in.getJsonWriter()
jsonWriter.key("highLimit")
jsonWriter.value("1024")
// do not close writer
return null
}