Index: dm/DMJsonWriter.cpp |
diff --git a/dm/DMJsonWriter.cpp b/dm/DMJsonWriter.cpp |
index c8334c5ccea2fbc67aaa4fd893bdb7b078b3ce23..4fe692432794c93e8f93f9312cb12d25f050c033 100644 |
--- a/dm/DMJsonWriter.cpp |
+++ b/dm/DMJsonWriter.cpp |
@@ -52,12 +52,17 @@ void JsonWriter::DumpJson() { |
SkAutoMutexAcquire lock(&gBitmapResultLock); |
for (int i = 0; i < gBitmapResults.count(); i++) { |
Json::Value result; |
- result["key"]["name"] = gBitmapResults[i].name.c_str(); |
- result["key"]["config"] = gBitmapResults[i].config.c_str(); |
- result["key"]["source_type"] = gBitmapResults[i].sourceType.c_str(); |
- result["key"]["source_options"] = gBitmapResults[i].sourceOptions.c_str(); |
- result["options"]["ext"] = gBitmapResults[i].ext.c_str(); |
- result["md5"] = gBitmapResults[i].md5.c_str(); |
+ result["key"]["name"] = gBitmapResults[i].name.c_str(); |
+ result["key"]["config"] = gBitmapResults[i].config.c_str(); |
+ result["key"]["source_type"] = gBitmapResults[i].sourceType.c_str(); |
+ result["options"]["ext"] = gBitmapResults[i].ext.c_str(); |
+ result["md5"] = gBitmapResults[i].md5.c_str(); |
+ |
+ // Source options only need to be part of the key if they exist. |
+ // Source type by source type, we either always set options or never set options. |
+ if (!gBitmapResults[i].sourceOptions.isEmpty()) { |
+ result["key"]["source_options"] = gBitmapResults[i].sourceOptions.c_str(); |
+ } |
root["results"].append(result); |
} |