public class JsonGenUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
INFINITE |
static java.lang.String |
NAN |
| Constructor and Description |
|---|
JsonGenUtils() |
| Modifier and Type | Method and Description |
|---|---|
static com.google.protobuf.Message.Builder |
jsonToMessage(javax.json.JsonObject jsonObject,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
Method to convert a jsonObject to a Message Builder.
|
static com.google.protobuf.Message.Builder |
jsonToMessage(javax.json.JsonObject jsonObject,
com.google.protobuf.Message.Builder builder,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
Method to convert a jsonObject to a Message Builder.
|
static java.lang.String |
jsonToString(java.lang.Object jsonBuilder,
boolean prettyPrint)
Help method to convert a json object to string representation.
|
static javax.json.JsonObjectBuilder |
messageToJson(com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
Method to convert a Proto Message to JSON.
|
static void |
readRepeatedValue(javax.json.JsonArray jsonArray,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
Method to read a json array into a repeated value in related message.
|
static void |
readSingleValue(javax.json.JsonObject jsonObject,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
Method to read and set a single value that is not a repeated or a map.
|
static void |
setRepeatedValue(javax.json.JsonObjectBuilder jsonObjectBuilder,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
Method to create json array of a repeated field.
|
static void |
setSingleValue(javax.json.JsonObjectBuilder jsonObjectBuilder,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
Sets a json value of an non repeated nor mapped field.
|
public static final java.lang.String INFINITE
public static final java.lang.String NAN
public static java.lang.String jsonToString(java.lang.Object jsonBuilder,
boolean prettyPrint)
throws javax.json.JsonException
jsonBuilder - the json data to convert, either JsonObjectBuilder or JsonArrayBuilder.prettyPrint - true if json data should be pretty printed with indentation and newlines.javax.json.JsonException - if problems occurred converting to string.public static void readSingleValue(javax.json.JsonObject jsonObject,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
throws javax.json.JsonException
jsonObject - json object to read a value from.apiObjectBuilder - the api object builder to set value into.fieldDescriptor - the field descriptorjavax.json.JsonException - if internal problems occurred converting the json data to message.public static void setSingleValue(javax.json.JsonObjectBuilder jsonObjectBuilder,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
jsonObjectBuilder - the json object being builtapiObjectBuilder - the related apiObjectfieldDescriptor - the field descriptorpublic static javax.json.JsonObjectBuilder messageToJson(com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
apiObjectBuilder - the proto message builder to convert.messageDescriptor - the descriptor of the message.public static com.google.protobuf.Message.Builder jsonToMessage(javax.json.JsonObject jsonObject,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
throws javax.json.JsonException
jsonObject - the json object to return.messageDescriptor - the descriptor of the message to convert.javax.json.JsonException - if internal problems occurred converting the json data to message.public static com.google.protobuf.Message.Builder jsonToMessage(javax.json.JsonObject jsonObject,
com.google.protobuf.Message.Builder builder,
com.google.protobuf.Descriptors.Descriptor messageDescriptor)
throws javax.json.JsonException
jsonObject - the json object to return.messageDescriptor - the descriptor of the message to convert.javax.json.JsonException - if internal problems occurred converting the json data to message.public static void setRepeatedValue(javax.json.JsonObjectBuilder jsonObjectBuilder,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
jsonObjectBuilder - the json object to add json array to.apiObjectBuilder - the proto message builder to convert.fieldDescriptor - the descriptor of the field.public static void readRepeatedValue(javax.json.JsonArray jsonArray,
com.google.protobuf.Message.Builder apiObjectBuilder,
com.google.protobuf.Descriptors.FieldDescriptor fieldDescriptor)
throws javax.json.JsonException
jsonArray - the json array to read values from.apiObjectBuilder - the api object builder to set value into.fieldDescriptor - the field descriptorjavax.json.JsonException - if internal problems occurred converting the json data to message.