Specifying JSON within Command-Line Options

Some gfsh commands allow JSON specifications within some options. These JSON strings specify initialization properties in the form of key/value pairs.

A JSON string is appended to a fully qualified class name, for those classes that implement the Declarable interface. The parameter to the interface’s init method is an object that contains initialization properties. The JSON string is parsed and broken into a set of property names and values that define the object.

The specification of a cache loader class in the gfsh create region command may have a JSON specification. For example,

gfsh>create region --name=region1 --type=PARTITION \
   --cache-loader=com.example.Setup{'k1':'v1','k2':'v2','k3':'v3'} 

The JSON string in this example is

{'k1':'v1','k2':'v2','k3':'v3'} 

The JSON string is surrounded by curly braces, and the pairs are separated by commas.
Each pair is separated by a colon. Each of the two strings that define a pair is enclosed with single or double quote characters. Be consistent throughout the JSON string in the use of either single or double quote characters.

Space characters separate gfsh command-line options, and the tokenizing of the options occurs before the parsing of JSON strings. If the value within the command-line option contains a space, delimit it with double quote marks.

As an example, assume that there is a single pair, and the value of the pair is value with space. The right-hand side of the --cache-loader example option becomes

gfsh>create region --name=region2 --type=PARTITION \
   --cache-loader="com.example.Setup{'k1':'value with space'}" 

To incorporate a single quote character within a value, escape it with two backslash characters. For example,

gfsh>create region --name=region3 --type=PARTITION \
   --cache-loader="com.example.Setup{'k1':'property\\'s value'}" 

The value of the pair is property's value.