From f5a271611bb3bf00d6c9ffa495b7a29c0b235ce8 Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Mon, 27 May 2019 12:41:16 +0000 Subject: [PATCH] [WSO2-Release] [Release 2.0.1] update documentation for release 2.0.1 --- README.md | 28 +- docs/api/2.0.1.md | 673 +++++++++++++++++++++++++++++++++++++++++++++ docs/api/latest.md | 2 +- docs/index.md | 28 +- mkdocs.yml | 1 + 5 files changed, 703 insertions(+), 29 deletions(-) create mode 100644 docs/api/2.0.1.md diff --git a/README.md b/README.md index d7d1914..f47656e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Find some useful links below: ## Latest API Docs -Latest API Docs is 2.0.0. +Latest API Docs is 2.0.1. ## How to use @@ -47,19 +47,19 @@ directory. ## Features -* getBool *(Function)*

This method returns a 'boolean' value, either 'true' or 'false', based on the valuespecified against the JSON element present in the given path.In case there is no valid boolean value found in the given path, the method still returns 'false'.

-* getDouble *(Function)*

This method returns the double value of the JSON element present in the given path. If there is no valid double value in the given path, the method returns 'null'.

-* getFloat *(Function)*

This method returns the float value of the JSON element present in the given path.If there is no valid float value in the given path, the method returns 'null'.

-* getInt *(Function)*

This method returns the integer value of the JSON element present in the given path. If there is no valid integer value in the given path, the method returns 'null'.

-* getLong *(Function)*

This returns the long value of the JSON element present in the given path. Ifthere is no valid long value in the given path, the method returns 'null'.

-* getObject *(Function)*

This returns the object of the JSON element present in the given path.

-* getString *(Function)*

This returns the string value of the JSON element present in the given path.

-* isExists *(Function)*

This method checks whether there is a JSON element present in the given path or not.If there is a valid JSON element in the given path, it returns 'true'. If there is no valid JSON element, it returns 'false'

-* setElement *(Function)*

This method allows to insert elements into a given JSON present in a specific path. If there is no valid path given, it returns the original JSON. Otherwise, it returns the new JSON.

-* toObject *(Function)*

This method returns the JSON object related to a given JSON string.

-* toString *(Function)*

This method returns the JSON string corresponding to a given JSON object.

-* tokenize *(Stream Processor)*

This tokenizes the given json according the path provided

-* tokenizeAsObject *(Stream Processor)*

This tokenizes the given JSON based on the path provided and returns the response as an object.

+* getBool *(Function)*

This method returns a 'boolean' value, either 'true' or 'false', based on the valuespecified against the JSON element present in the given path.In case there is no valid boolean value found in the given path, the method still returns 'false'.

+* getDouble *(Function)*

This method returns the double value of the JSON element present in the given path. If there is no valid double value in the given path, the method returns 'null'.

+* getFloat *(Function)*

This method returns the float value of the JSON element present in the given path.If there is no valid float value in the given path, the method returns 'null'.

+* getInt *(Function)*

This method returns the integer value of the JSON element present in the given path. If there is no valid integer value in the given path, the method returns 'null'.

+* getLong *(Function)*

This returns the long value of the JSON element present in the given path. Ifthere is no valid long value in the given path, the method returns 'null'.

+* getObject *(Function)*

This returns the object of the JSON element present in the given path.

+* getString *(Function)*

This returns the string value of the JSON element present in the given path.

+* isExists *(Function)*

This method checks whether there is a JSON element present in the given path or not.If there is a valid JSON element in the given path, it returns 'true'. If there is no valid JSON element, it returns 'false'

+* setElement *(Function)*

This method allows to insert elements into a given JSON present in a specific path. If there is no valid path given, it returns the original JSON. Otherwise, it returns the new JSON.

+* toObject *(Function)*

This method returns the JSON object related to a given JSON string.

+* toString *(Function)*

This method returns the JSON string corresponding to a given JSON object.

+* tokenize *(Stream Processor)*

This tokenizes the given json according the path provided

+* tokenizeAsObject *(Stream Processor)*

This tokenizes the given JSON based on the path provided and returns the response as an object.

## How to Contribute diff --git a/docs/api/2.0.1.md b/docs/api/2.0.1.md new file mode 100644 index 0000000..d593667 --- /dev/null +++ b/docs/api/2.0.1.md @@ -0,0 +1,673 @@ +# API Docs - v2.0.1 + +## Json + +### getBool *(Function)* + +

This method returns a 'boolean' value, either 'true' or 'false', based on the valuespecified against the JSON element present in the given path.In case there is no valid boolean value found in the given path, the method still returns 'false'.

+ +Syntax +``` + json:getBool( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the boolean value in the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON from which the 'getBool' function fetches theboolean value.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getBool(json,"$.name") as name +insert into OutputStream; +``` +

This returns the boolean value of the JSON input in the given path. The results are directed to the 'OutputStream' stream.

+ +### getDouble *(Function)* + +

This method returns the double value of the JSON element present in the given path. If there is no valid double value in the given path, the method returns 'null'.

+ +Syntax +``` + json:getDouble( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON from which the 'getDouble' function fetches thedouble value.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getDouble(json,"$.name") as name +insert into OutputStream; +``` +

This returns the double value of the given path. The results aredirected to the 'OutputStream' stream.

+ +### getFloat *(Function)* + +

This method returns the float value of the JSON element present in the given path.If there is no valid float value in the given path, the method returns 'null'.

+ +Syntax +``` + json:getFloat( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON from which the 'getFloat' function fetches thevalue.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getFloat(json,"$.name") as name +insert into OutputStream; +``` +

This returns the float value of the JSON input in the given path. The results aredirected to the 'OutputStream' stream.

+ +### getInt *(Function)* + +

This method returns the integer value of the JSON element present in the given path. If there is no valid integer value in the given path, the method returns 'null'.

+ +Syntax +``` + json:getInt( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON from which the 'getInt' function fetches theinteger value.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getInt(json,"$.name") as name +insert into OutputStream; +``` +

This returns the integer value of the JSON input in the given path. The resultsare directed to the 'OutputStream' stream.

+ +### getLong *(Function)* + +

This returns the long value of the JSON element present in the given path. Ifthere is no valid long value in the given path, the method returns 'null'.

+ +Syntax +``` + json:getLong( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the JSON element from which the 'getLong' functionfetches the long value.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getLong(json,"$.name") as name +insert into OutputStream; +``` +

This returns the long value of the JSON input in the given path. The results aredirected to 'OutputStream' stream.

+ +### getObject *(Function)* + +

This returns the object of the JSON element present in the given path.

+ +Syntax +``` + json:getObject( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON from which the 'getObject' function fetches theobject.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getObject(json,"$.name") as name +insert into OutputStream; +``` +

This returns the object of the JSON input in the given path. The results are directed to the 'OutputStream' stream.

+ +### getString *(Function)* + +

This returns the string value of the JSON element present in the given path.

+ +Syntax +``` + json:getString( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input that holds the value in the given path.STRING
OBJECT
NoNo
pathThe path of the JSON input from which the 'getString' function fetches the string value.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:getString(json,"$.name") as name +insert into OutputStream; +``` +

This returns the string value of the JSON input in the given path. The results are directed to the 'OutputStream' stream.

+ +### isExists *(Function)* + +

This method checks whether there is a JSON element present in the given path or not.If there is a valid JSON element in the given path, it returns 'true'. If there is no valid JSON element, it returns 'false'

+ +Syntax +``` + json:isExists( json, path) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input in a given path, on which the function performs the search forJSON elements.STRING
OBJECT
NoNo
pathThe path that contains the input JSON on which the function performs the search.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:isExists(json,"$.name") as name +insert into OutputStream; +``` +

This returns either true or false based on the existence of a JSON element in a given path. The results are directed to the 'OutputStream' stream.

+ +### setElement *(Function)* + +

This method allows to insert elements into a given JSON present in a specific path. If there is no valid path given, it returns the original JSON. Otherwise, it returns the new JSON.

+ +Syntax +``` + json:setElement( json, path, jsonelement, key) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe JSON input into which is this function inserts the new value.STRING
OBJECT
NoNo
pathThe path on the JSON input which is used to insert the given element.STRINGNoNo
jsonelementThe JSON element which is inserted by the function into the input JSON.STRING
BOOL
DOUBLE
FLOAT
INT
LONG
OBJECT
NoNo
keyThe key which is used to insert the given element into the input JSON.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:setElement(json,"$.name") as name +insert into OutputStream; +``` +

This returns the JSON object present in the given path with the newly inserted JSONelement. The results are directed to the 'OutputStream' stream.

+ +### toObject *(Function)* + +

This method returns the JSON object related to a given JSON string.

+ +Syntax +``` + json:toObject( json) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonA valid JSON string from which the function generates the JSON object.STRINGNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:toJson(json) as jsonObject +insert into OutputStream; +``` +

This returns the JSON object corresponding to the given JSON string.The results aredirected to the 'OutputStream' stream.

+ +### toString *(Function)* + +

This method returns the JSON string corresponding to a given JSON object.

+ +Syntax +``` + json:toString( json) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonA valid JSON object from which the function generates a JSON string.OBJECTNoNo
+ +Examples +EXAMPLE 1 +``` +define stream InputStream(json string); +from InputStream +select json:toString(json) as jsonString +insert into OutputStream; +``` +

This returns the JSON string corresponding to a given JSON object. The results are directed to the 'OutputStream' stream.

+ +### tokenize *(Stream Processor)* + +

This tokenizes the given json according the path provided

+ +Syntax +``` +json:tokenize( json, path, fail.on.missing.attribute) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe input json that should be tokenized using the given path.STRING
OBJECT
NoNo
pathThe path that is used to tokenize the given jsonSTRINGNoNo
fail.on.missing.attributeIf this parameter is set to 'true' and a json is not provided in the given path, the event is dropped. If the parameter is set to 'false', the unavailability of a json in the specified path results in the event being created with a 'null' value for the json element.trueBOOLYesNo
+Extra Return Attributes + + + + + + + + + + + +
NameDescriptionPossible Types
jsonElementThe json element retrieved based on the given path and the json.STRING
+ +Examples +EXAMPLE 1 +``` +define stream InputStream (json string,path string); +@info(name = 'query1') +from InputStream#json:tokenize(json, path) +select jsonElement +insert into OutputStream; +``` +

This query performs a tokenization for the given json using the path specified. If the specified path provides a json array, it generates events for each element in that array by adding an additional attributes as the 'jsonElement' to the stream.
e.g., + jsonInput - {name:"John",enrolledSubjects:["Mathematics","Physics"]}, + path - "$.enrolledSubjects" +
 If we use the configuration in this example, it generates two events with the attributes "Mathematics", "Physics".
If the specified path provides a single json element, it adds the specified json element as an additional attribute named 'jsonElement' into the stream.
+ e.g., + jsonInput - {name:"John",age:25}, + path - "$.age" +

+ +### tokenizeAsObject *(Stream Processor)* + +

This tokenizes the given JSON based on the path provided and returns the response as an object.

+ +Syntax +``` +json:tokenizeAsObject( json, path, fail.on.missing.attribute) +``` + +QUERY PARAMETERS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jsonThe input json that is tokenized using the given path.STRING
OBJECT
NoNo
pathThe path of the input JSON that the function tokenizes.STRINGNoNo
fail.on.missing.attributeIf this parameter is set to 'true' and a JSON is not provided in the given path, the event is dropped. If the parameter is set to 'false', the unavailability of a JSON in the specified path results in the event being created with a 'null' value for the json element.trueBOOLYesNo
+Extra Return Attributes + + + + + + + + + + + +
NameDescriptionPossible Types
jsonElementThe JSON element retrieved based on the given path and the JSON.OBJECT
+ +Examples +EXAMPLE 1 +``` +define stream InputStream (json string,path string); +@info(name = 'query1') +from InputStream#json:tokenizeAsObject(json, path) +select jsonElement +insert into OutputStream; +``` +

This query performs a tokenization for the given JSON using the path specified. If the specified path provides a JSON array, it generates events for each element in the specified json array by adding an additional attribute as the 'jsonElement' into the stream.
e.g., + jsonInput - {name:"John",enrolledSubjects:["Mathematics","Physics"]}, + path - "$.enrolledSubjects" +
If we use the configuration in the above example, it generates two events with the attributes "Mathematics" and "Physics".
If the specified path provides a single json element, it adds the specified json element as an additional attribute named 'jsonElement' into the stream
+ e.g., + jsonInput - {name:"John",age:25}, + path - "$.age" +

+ diff --git a/docs/api/latest.md b/docs/api/latest.md index 2b80cfa..d593667 100644 --- a/docs/api/latest.md +++ b/docs/api/latest.md @@ -1,4 +1,4 @@ -# API Docs - v2.0.0 +# API Docs - v2.0.1 ## Json diff --git a/docs/index.md b/docs/index.md index d7d1914..f47656e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,7 +11,7 @@ Find some useful links below: ## Latest API Docs -Latest API Docs is 2.0.0. +Latest API Docs is 2.0.1. ## How to use @@ -47,19 +47,19 @@ directory. ## Features -* getBool *(Function)*

This method returns a 'boolean' value, either 'true' or 'false', based on the valuespecified against the JSON element present in the given path.In case there is no valid boolean value found in the given path, the method still returns 'false'.

-* getDouble *(Function)*

This method returns the double value of the JSON element present in the given path. If there is no valid double value in the given path, the method returns 'null'.

-* getFloat *(Function)*

This method returns the float value of the JSON element present in the given path.If there is no valid float value in the given path, the method returns 'null'.

-* getInt *(Function)*

This method returns the integer value of the JSON element present in the given path. If there is no valid integer value in the given path, the method returns 'null'.

-* getLong *(Function)*

This returns the long value of the JSON element present in the given path. Ifthere is no valid long value in the given path, the method returns 'null'.

-* getObject *(Function)*

This returns the object of the JSON element present in the given path.

-* getString *(Function)*

This returns the string value of the JSON element present in the given path.

-* isExists *(Function)*

This method checks whether there is a JSON element present in the given path or not.If there is a valid JSON element in the given path, it returns 'true'. If there is no valid JSON element, it returns 'false'

-* setElement *(Function)*

This method allows to insert elements into a given JSON present in a specific path. If there is no valid path given, it returns the original JSON. Otherwise, it returns the new JSON.

-* toObject *(Function)*

This method returns the JSON object related to a given JSON string.

-* toString *(Function)*

This method returns the JSON string corresponding to a given JSON object.

-* tokenize *(Stream Processor)*

This tokenizes the given json according the path provided

-* tokenizeAsObject *(Stream Processor)*

This tokenizes the given JSON based on the path provided and returns the response as an object.

+* getBool *(Function)*

This method returns a 'boolean' value, either 'true' or 'false', based on the valuespecified against the JSON element present in the given path.In case there is no valid boolean value found in the given path, the method still returns 'false'.

+* getDouble *(Function)*

This method returns the double value of the JSON element present in the given path. If there is no valid double value in the given path, the method returns 'null'.

+* getFloat *(Function)*

This method returns the float value of the JSON element present in the given path.If there is no valid float value in the given path, the method returns 'null'.

+* getInt *(Function)*

This method returns the integer value of the JSON element present in the given path. If there is no valid integer value in the given path, the method returns 'null'.

+* getLong *(Function)*

This returns the long value of the JSON element present in the given path. Ifthere is no valid long value in the given path, the method returns 'null'.

+* getObject *(Function)*

This returns the object of the JSON element present in the given path.

+* getString *(Function)*

This returns the string value of the JSON element present in the given path.

+* isExists *(Function)*

This method checks whether there is a JSON element present in the given path or not.If there is a valid JSON element in the given path, it returns 'true'. If there is no valid JSON element, it returns 'false'

+* setElement *(Function)*

This method allows to insert elements into a given JSON present in a specific path. If there is no valid path given, it returns the original JSON. Otherwise, it returns the new JSON.

+* toObject *(Function)*

This method returns the JSON object related to a given JSON string.

+* toString *(Function)*

This method returns the JSON string corresponding to a given JSON object.

+* tokenize *(Stream Processor)*

This tokenizes the given json according the path provided

+* tokenizeAsObject *(Stream Processor)*

This tokenizes the given JSON based on the path provided and returns the response as an object.

## How to Contribute diff --git a/mkdocs.yml b/mkdocs.yml index 974cd24..815a860 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -32,6 +32,7 @@ markdown_extensions: pages: - Welcome: index.md - API Docs: + - 2.0.1: api/2.0.1.md - 2.0.0: api/2.0.0.md - 1.1.1: api/1.1.1.md - 1.1.0: api/1.1.0.md