Package org.a2aproject.sdk.grpc.utils
Class ProtoJsonUtils
java.lang.Object
org.a2aproject.sdk.grpc.utils.ProtoJsonUtils
Protobuf-to-JSON serialization without HTML escaping.
JsonFormat.printer() delegates to Gson's JsonWriter
which HTML-escapes <, >, and & by default. This utility
removes those escape sequences via HtmlEscapeUtils.removeHtmlEscaping(String).
-
Method Summary
-
Method Details
-
toJson
public static String toJson(com.google.protobuf.util.JsonFormat.Printer printer, @Nullable com.google.protobuf.MessageOrBuilder proto) throws com.google.protobuf.InvalidProtocolBufferException Serializes a protobuf message to JSON using the supplied printer, then removes HTML escaping.- Parameters:
printer- the configuredJsonFormat.Printer(callers choose options such asalwaysPrintFieldsWithNoPresence()oromittingInsignificantWhitespace())proto- the protobuf message to serialize, ornull- Returns:
- JSON string without HTML-escaped characters, or empty string if proto is null
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-