Package com.google.cloud.logging
Class Payload.JsonPayload
java.lang.Object
com.google.cloud.logging.Payload<com.google.protobuf.Struct>
com.google.cloud.logging.Payload.JsonPayload
- All Implemented Interfaces:
Serializable
A log entry's JSON payload.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.cloud.logging.Payload
Payload.JsonPayload, Payload.ProtoPayload, Payload.StringPayload, Payload.Type
-
Method Summary
Modifier and TypeMethodDescriptionReturns the log entry's JSON data as an unmodifiable map.static Payload.JsonPayload
of
(com.google.protobuf.Struct data) Creates a log entry payload given its JSON data represented as a protobuf struct.static Payload.JsonPayload
Creates a log entry payload given its JSON data represented as a map.
-
Method Details
-
getDataAsMap
Returns the log entry's JSON data as an unmodifiable map. -
of
Creates a log entry payload given its JSON data represented as a map. The provided map is copied into aStruct
object.Notice that all numbers (int, long, float and double) are serialized as double values. Enums are serialized as strings.
Example usage of
JsonPayload
:List<Long> listValue = Arrays.asList(1L, 2L); Map<String, Object> innerMap = new HashMap<String, Object>(); innerMap.put("booleanValue", true); innerMap.put("stringValue", "stringValue"); Map<String, Object> jsonContent = new HashMap<String, Object>(); jsonContent.put("listValue", listValue); jsonContent.put("integerValue", 42); jsonContent.put("doubleValue", 42.0); jsonContent.put("stringValue", "stringValue"); jsonContent.put("mapValue", innerMap); JsonPayload payload = JsonPayload.of(jsonContent);
-
of
Creates a log entry payload given its JSON data represented as a protobuf struct.
-