public final class TupleJSONUtil
extends java.lang.Object
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
TupleJSONUtil.Options
Options for serializing JSON. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
static java.lang.String | 
jsonPath(java.lang.String json,
        java.lang.String jsonPath)
Return the string representation of objects extracted from json according to path 
 | 
static void | 
setTuple(Tuple tuple,
        java.lang.Object jsonObject,
        boolean strict)
Set the fields of a tuple based on the contents of a JSON object 
 | 
static void | 
setTuple(Tuple tuple,
        java.lang.Object jsonObject,
        boolean strict,
        java.lang.String timestampFormat)
Set the fields of a tuple based on the contents of a JSON object 
 | 
static void | 
setTuple(Tuple tuple,
        java.lang.Object jsonObject,
        boolean strict,
        java.lang.String timestampFormat,
        boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON object 
 | 
static void | 
setTupleFromJSON(Tuple tuple,
                java.lang.String JSONString)
Set the fields of a tuple based on the contents of a JSON string 
 | 
static void | 
setTupleFromJSON(Tuple tuple,
                java.lang.String JSONString,
                java.lang.String timestampFormat)
Set the fields of a tuple based on the contents of a JSON string 
 | 
static void | 
setTupleFromJSON(Tuple tuple,
                java.lang.String JSONString,
                java.lang.String timestampFormat,
                boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON string 
 | 
static void | 
setTupleFromJSONLoose(Tuple tuple,
                     java.lang.String JSONString)
Set the fields of a tuple based on the contents of a JSON string. 
 | 
static void | 
setTupleFromJSONLoose(Tuple tuple,
                     java.lang.String JSONString,
                     java.lang.String timestampFormat)
Set the fields of a tuple based on the contents of a JSON string. 
 | 
static void | 
setTupleFromJSONLoose(Tuple tuple,
                     java.lang.String JSONString,
                     java.lang.String timestampFormat,
                     boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON string. 
 | 
static java.lang.String | 
toJSONListString(Tuple tuple)
Return the JSON string representation of the supplied tuple. 
 | 
static java.lang.String | 
toJSONListString(Tuple tuple,
                java.lang.String timeStampFormat)
Return the JSON string representation of the supplied tuple. 
 | 
static java.lang.String | 
toJSONMapString(Tuple tuple)
Return the JSON string representation of the supplied tuple. 
 | 
static java.lang.String | 
toJSONMapString(Tuple tuple,
               java.lang.String timeStampFormat)
Return the JSON string representation of the supplied tuple. 
 | 
static java.lang.String | 
toJSONMapStringSingleQuote(Tuple tuple)
Return the single quote JSON string representation of the supplied tuple. 
 | 
static java.lang.String | 
toJSONString(java.util.Collection<Tuple> tuples)  | 
static java.lang.String | 
toJSONString(Tuple t,
            java.util.EnumSet<TupleJSONUtil.Options> options)
Convert a tuple to its JSON representation. 
 | 
static java.lang.String | 
toJSONString(Tuple t,
            java.util.EnumSet<TupleJSONUtil.Options> options,
            java.lang.String timestampFormat)
Convert a tuple to its JSON representation. 
 | 
public static void setTuple(Tuple tuple, java.lang.Object jsonObject, boolean strict) throws StreamBaseException
tuple - the tuple to setjsonObject - the JSON object; must have at least the fields of the tuple's schemastrict - whether to throw an exception when fields are missing from tuple's schemacom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTuple(Tuple tuple, java.lang.Object jsonObject, boolean strict, java.lang.String timestampFormat) throws StreamBaseException
tuple - the tuple to setjsonObject - the JSON object; must have at least the fields of the tuple's schemastrict - whether to throw an exception when fields are missing from tuple's schematimestampFormat - the timestamp format to use when convertingcom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTuple(Tuple tuple, java.lang.Object jsonObject, boolean strict, java.lang.String timestampFormat, boolean numericTimestampsAsInterval) throws StreamBaseException
tuple - the tuple to setjsonObject - the JSON object; must have at least the fields of the tuple's schemastrict - whether to throw an exception when fields are missing from tuple's schematimestampFormat - the timestamp format to use when convertingnumericTimestampsAsInterval - If true any numeric values in a timestamp field will be converted to interval types, if false they are considered timestampcom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTupleFromJSON(Tuple tuple, java.lang.String JSONString) throws StreamBaseException
tuple - the tuple to setJSONString - the JSON string; must have at least the fields of the tuple's schemacom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTupleFromJSON(Tuple tuple, java.lang.String JSONString, java.lang.String timestampFormat) throws StreamBaseException
tuple - the tuple to setJSONString - the JSON string; must have at least the fields of the tuple's schematimestampFormat - the timestamp format to use when convertingcom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTupleFromJSON(Tuple tuple, java.lang.String JSONString, java.lang.String timestampFormat, boolean numericTimestampsAsInterval) throws StreamBaseException
tuple - the tuple to setJSONString - the JSON string; must have at least the fields of the tuple's schematimestampFormat - the timestamp format to use when convertingnumericTimestampsAsInterval - If true any numeric values in a timestamp field will be converted to interval types, if false they are considered timestampcom.alibaba.fastjson.JSONExceptionStreamBaseExceptionpublic static void setTupleFromJSONLoose(Tuple tuple, java.lang.String JSONString) throws StreamBaseException
tuple - JSONString - StreamBaseExceptionpublic static void setTupleFromJSONLoose(Tuple tuple, java.lang.String JSONString, java.lang.String timestampFormat) throws StreamBaseException
tuple - JSONString - timestampFormat - StreamBaseExceptionpublic static void setTupleFromJSONLoose(Tuple tuple, java.lang.String JSONString, java.lang.String timestampFormat, boolean numericTimestampsAsInterval) throws StreamBaseException
tuple - JSONString - timestampFormat - numericTimestampsAsInterval - If true any numeric values in a timestamp field will be converted to interval types, if false they are considered timestampStreamBaseExceptionpublic static java.lang.String toJSONString(Tuple t, java.util.EnumSet<TupleJSONUtil.Options> options)
t - The tuple to serializeoptions - The serialization options TupleJSONUtil.Optionspublic static java.lang.String toJSONString(Tuple t, java.util.EnumSet<TupleJSONUtil.Options> options, java.lang.String timestampFormat)
t - The tuple to serializeoptions - The serialization options TupleJSONUtil.OptionstimestampFormat - the timestamp format to use when convertingpublic static java.lang.String toJSONMapString(Tuple tuple, java.lang.String timeStampFormat)
tuple - The tuple to serializetimeStampFormat - the timestamp format to use when convertingpublic static java.lang.String toJSONMapString(Tuple tuple)
tuple - The tuple to serializepublic static java.lang.String toJSONListString(Tuple tuple, java.lang.String timeStampFormat)
tuple - The tuple to serializetimeStampFormat - the timestamp format to use when convertingpublic static java.lang.String toJSONListString(Tuple tuple)
tuple - The tuple to serializepublic static java.lang.String toJSONMapStringSingleQuote(Tuple tuple)
tuple - The tuple to serializepublic static java.lang.String jsonPath(java.lang.String json,
                                        java.lang.String jsonPath)
See http://code.google.com/p/json-path/ for full documentation.
json - string representation of json to parsejsonPath - string path to traverse to extract objects out of jsonpublic static java.lang.String toJSONString(java.util.Collection<Tuple> tuples)
tuples - the tuples to convert to JSON