Skip to content

Commit

Permalink
Merge branch 'prod_release-4.3.0.0' of
Browse files Browse the repository at this point in the history
.../githubEnterprise/streamsx.json into 1.5.x_m
  • Loading branch information
schulz2 committed Aug 7, 2018
2 parents 778ce24 + 5c31b10 commit d0d751e
Show file tree
Hide file tree
Showing 17 changed files with 3,065 additions and 124 deletions.
1 change: 1 addition & 0 deletions com.ibm.streamsx.json/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ com.ibm.streamsx.json/TupleToJSON
/output/
/build.xml~
/info.xml~
/.build.info
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<function:functions>
<function:function>
<function:description>
Convert a tuple to JSON object encoded as a serialized JSON String. Blob, complex and xml values are converted to nulls.
Convert a tuple to JSON object encoded as a serialized JSON String.
Blob, complex and xml values are converted to nulls. Timestamp is converted to a date string representation.
Optional attributes having null value are converted to null in JSON.
@param t Tuple to be converted to JSON.
@return Tuple encoded as a serialized JSON object.
</function:description>
Expand All @@ -24,6 +26,7 @@ Convert a tuple to JSON object encoded as a serialized JSON String. Blob, comple
<function:function>
<function:description>
Convert a map to JSON object encoded as a serialized JSON string. Blob, complex and xml values are converted to nulls.
Timestamp is converted to a date string representation.
@param m Map containing key-value pairs to be converted to JSON.
@return Serialized JSON object containing all name-value pairs in `m`.
</function:description>
Expand All @@ -41,6 +44,7 @@ Convert a map to JSON object encoded as a serialized JSON string. Blob, complex
<function:function>
<function:description>
Convert a value to JSON object with a single key encoded as a serialized JSON string. Blob, complex and xml values are converted to nulls.
An input value of type optional being null will generate also null in JSON.
@param key Key for name-value pair to be converted to JSON.
@param value Value for `key`.
@return Serialized JSON object containing single name-value pair.
Expand All @@ -59,9 +63,11 @@ Convert a value to JSON object with a single key encoded as a serialized JSON st
</function:function>
<function:function>
<function:description>
Extract values from JSON string accordingly to a given tuple.
Extract values from JSON string accordingly to a given tuple. Blob, complex, xml, timestamp and decimal type attributes are not supported.
Collections don't support nesting.
Optional types are supported for primitive types and list and set of primitive types only. Optional bounded types are not supported.
@param jsonString The input JSON string.
@param tuple A mutable tuple to save extracted values.
@param value A mutable tuple to save extracted values.
@return Reference to the input tuple.
</function:description>
<function:prototype>&lt;tuple T> public T extractFromJSON(rstring jsonString, mutable T value)</function:prototype>
Expand All @@ -84,6 +90,7 @@ Threading limitations:
Call to parseJSON should not be placed in param section or state of the operator (internally a json object is shared via the thread local storage).
@param jsonString The input JSON string.
@param status indicates a status of the parser (enum JsonParseStatus.status).
@param offset returns the offset in JSON string where parse error occured (use when status returns error).
@param jsonIndex Json index of enum type (e.g. enum\{_1\}).
@return Error code (0 - no error).
</function:description>
Expand Down
53 changes: 51 additions & 2 deletions com.ibm.streamsx.json/com.ibm.streamsx.json/types.spl
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,91 @@ namespace com.ibm.streamsx.json;
*/
type Json = rstring jsonString;


/**
* Defining types to be used in
* parseJSON() and queryJSON() functions
* value for parameter index. Each single one-value enum type
* represents an index to one parsed and internal stored JSON object
* which can be used later with queryJSON()
* by referencing the object with the index.
* So one can parse up to 20 JSON strings
* and work on them with queryJSON without
* re-parsing a JSON string when multiple querys
* should be done on it.
* Usage sample:
* parseJSON(yourJsonString, JsonIndex._1)
*/
public composite JsonIndex {
type
/** Single-value enum type with value JsonIndex._1 to reference internal stored JSON object */
static type_1 = enum{_1};
/** Single-value enum type with value JsonIndex._2 to reference internal stored JSON object */
static type_2 = enum{_2};
/** Single-value enum type with value JsonIndex._3 to reference internal stored JSON object */
static type_3 = enum{_3};
/** Single-value enum type with value JsonIndex._4 to reference internal stored JSON object */
static type_4 = enum{_4};
/** Single-value enum type with value JsonIndex._5 to reference internal stored JSON object */
static type_5 = enum{_5};
/** Single-value enum type with value JsonIndex._6 to reference internal stored JSON object */
static type_6 = enum{_6};
/** Single-value enum type with value JsonIndex._7 to reference internal stored JSON object */
static type_7 = enum{_7};
/** Single-value enum type with value JsonIndex._8 to reference internal stored JSON object */
static type_8 = enum{_8};
/** Single-value enum type with value JsonIndex._9 to reference internal stored JSON object */
static type_9 = enum{_9};
/** Single-value enum type with value JsonIndex._10 to reference internal stored JSON object */
static type_10 = enum{_10};
/** Single-value enum type with value JsonIndex._11 to reference internal stored JSON object */
static type_11 = enum{_11};
/** Single-value enum type with value JsonIndex._12 to reference internal stored JSON object */
static type_12 = enum{_12};
/** Single-value enum type with value JsonIndex._13 to reference internal stored JSON object */
static type_13 = enum{_13};
/** Single-value enum type with value JsonIndex._14 to reference internal stored JSON object */
static type_14 = enum{_14};
/** Single-value enum type with value JsonIndex._15 to reference internal stored JSON object */
static type_15 = enum{_15};
/** Single-value enum type with value JsonIndex._16 to reference internal stored JSON object */
static type_16 = enum{_16};
/** Single-value enum type with value JsonIndex._17 to reference internal stored JSON object */
static type_17 = enum{_17};
/** Single-value enum type with value JsonIndex._18 to reference internal stored JSON object */
static type_18 = enum{_18};
/** Single-value enum type with value JsonIndex._19 to reference internal stored JSON object */
static type_19 = enum{_19};
/** Single-value enum type with value JsonIndex._20 to reference internal stored JSON object */
static type_20 = enum{_20};
}

/**
* Definition of error codes which are returned when parsing a JSON string into
* internal JSON object. These are errors are caused by wrong formatted JSON string.
* Result of parseJSON().
*/
public composite JsonParseStatus {
type
/**
* Errors returned by parseJSON()
*/
static status = enum{PARSED, DOCUMENT_EMPTY, MULTIPLE_ROOTS, VALUE_INVALID, KEY_MISSING, COLON_MISSING,
OBJECT_COMMA_OR_BRACKET_MISSING, ARRAY_COMMA_OR_BRACKET_MISSING,
UNICODE_ESCAPE_INVALID, UNICODE_SURROGATE_INVALID,
STRING_ESCAPE_INVALID, STRING_QUOTATION_MISSING, STRING_INVALID_ENCODING,
NUMBER_TOO_BIG, NUMBER_MISS_FRACTION, NUMBER_MISS_EXPONENT, TERMINATION, SYNTAX_ERROR};
}

/**
* Definition of error codes which are returned when querying
* an internal JSON object (reference by JSONindex._? value) with a JSON path.
* Result of queryJSON().
*/
public composite JsonStatus {
type
/**
* Errors returned by queryJSON()
*/
static status = enum{FOUND, FOUND_CAST, FOUND_WRONG_TYPE, FOUND_NULL, NOT_FOUND,
PATH_MUST_BEGIN_WITH_SLASH, INVALID_ESCAPE, INVALID_PERCENT_ENCODING, CHAR_MUST_PERCENT_ENCODING};
}
}
Loading

0 comments on commit d0d751e

Please sign in to comment.