public final class TupleJSONUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TupleJSONUtil.Options
Options for serializing JSON.
|
Modifier and Type | Method and Description |
---|---|
static String |
jsonPath(String json,
String jsonPath)
Return the string representation of objects extracted from json according to path
|
static void |
setTuple(Tuple tuple,
Object jsonObject,
boolean strict)
Set the fields of a tuple based on the contents of a JSON object
|
static void |
setTuple(Tuple tuple,
Object jsonObject,
boolean strict,
String timestampFormat)
Set the fields of a tuple based on the contents of a JSON object
|
static void |
setTuple(Tuple tuple,
Object jsonObject,
boolean strict,
String timestampFormat,
boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON object
|
static void |
setTupleFromJSON(Tuple tuple,
String JSONString)
Set the fields of a tuple based on the contents of a JSON string
|
static void |
setTupleFromJSON(Tuple tuple,
String JSONString,
String timestampFormat)
Set the fields of a tuple based on the contents of a JSON string
|
static void |
setTupleFromJSON(Tuple tuple,
String JSONString,
String timestampFormat,
boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON string
|
static void |
setTupleFromJSONLoose(Tuple tuple,
String JSONString)
Set the fields of a tuple based on the contents of a JSON string.
|
static void |
setTupleFromJSONLoose(Tuple tuple,
String JSONString,
String timestampFormat)
Set the fields of a tuple based on the contents of a JSON string.
|
static void |
setTupleFromJSONLoose(Tuple tuple,
String JSONString,
String timestampFormat,
boolean numericTimestampsAsInterval)
Set the fields of a tuple based on the contents of a JSON string.
|
static String |
toJSONListString(Tuple tuple)
Return the JSON string representation of the supplied tuple.
|
static String |
toJSONListString(Tuple tuple,
String timeStampFormat)
Return the JSON string representation of the supplied tuple.
|
static String |
toJSONMapString(Tuple tuple)
Return the JSON string representation of the supplied tuple.
|
static String |
toJSONMapString(Tuple tuple,
String timeStampFormat)
Return the JSON string representation of the supplied tuple.
|
static String |
toJSONMapStringSingleQuote(Tuple tuple)
Return the single quote JSON string representation of the supplied tuple.
|
static String |
toJSONString(Collection<Tuple> tuples) |
static String |
toJSONString(Tuple t,
EnumSet<TupleJSONUtil.Options> options)
Convert a tuple to its JSON representation.
|
static String |
toJSONString(Tuple t,
EnumSet<TupleJSONUtil.Options> options,
String timestampFormat)
Convert a tuple to its JSON representation.
|
public static void setTuple(Tuple tuple, 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.JSONException
StreamBaseException
public static void setTuple(Tuple tuple, Object jsonObject, boolean strict, 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.JSONException
StreamBaseException
public static void setTuple(Tuple tuple, Object jsonObject, boolean strict, 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.JSONException
StreamBaseException
public static void setTupleFromJSON(Tuple tuple, 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.JSONException
StreamBaseException
public static void setTupleFromJSON(Tuple tuple, String JSONString, 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.JSONException
StreamBaseException
public static void setTupleFromJSON(Tuple tuple, String JSONString, 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.JSONException
StreamBaseException
public static void setTupleFromJSONLoose(Tuple tuple, String JSONString) throws StreamBaseException
tuple
- JSONString
- StreamBaseException
public static void setTupleFromJSONLoose(Tuple tuple, String JSONString, String timestampFormat) throws StreamBaseException
tuple
- JSONString
- timestampFormat
- StreamBaseException
public static void setTupleFromJSONLoose(Tuple tuple, String JSONString, 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 timestampStreamBaseException
public static String toJSONString(Tuple t, EnumSet<TupleJSONUtil.Options> options)
t
- The tuple to serializeoptions
- The serialization options TupleJSONUtil.Options
public static String toJSONString(Tuple t, EnumSet<TupleJSONUtil.Options> options, String timestampFormat)
t
- The tuple to serializeoptions
- The serialization options TupleJSONUtil.Options
timestampFormat
- the timestamp format to use when convertingpublic static String toJSONMapString(Tuple tuple, String timeStampFormat)
tuple
- The tuple to serializetimeStampFormat
- the timestamp format to use when convertingpublic static String toJSONMapString(Tuple tuple)
tuple
- The tuple to serializepublic static String toJSONListString(Tuple tuple, String timeStampFormat)
tuple
- The tuple to serializetimeStampFormat
- the timestamp format to use when convertingpublic static String toJSONListString(Tuple tuple)
tuple
- The tuple to serializepublic static String toJSONMapStringSingleQuote(Tuple tuple)
tuple
- The tuple to serializepublic static String jsonPath(String json, 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 String toJSONString(Collection<Tuple> tuples)
tuples
- the tuples to convert to JSON