Search in sources :

Example 1 with MapEntry

use of com.google.protobuf.MapEntry in project sonarqube by SonarSource.

the class ProtobufJsonFormat method writeMap.

private static void writeMap(Collection<MapEntry> mapEntries, JsonWriter writer) {
    writer.beginObject();
    for (MapEntry mapEntry : mapEntries) {
        // Key fields are always double-quoted in json
        writer.name(mapEntry.getKey().toString());
        Descriptors.FieldDescriptor valueDescriptor = mapEntry.getDescriptorForType().findFieldByName("value");
        writeFieldValue(valueDescriptor, mapEntry.getValue(), writer);
    }
    writer.endObject();
}
Also used : MapEntry(com.google.protobuf.MapEntry) Descriptors(com.google.protobuf.Descriptors)

Aggregations

Descriptors (com.google.protobuf.Descriptors)1 MapEntry (com.google.protobuf.MapEntry)1