Skip to content

Commit d3577c9

Browse files
meteorcloudycopybara-github
authored andcommitted
Bzlmod lockfile: fix pretty printing for attributes
RELNOTES: PiperOrigin-RevId: 569510142 Change-Id: I46f3db411c720b79f3474da67a5b1614a0b7815f
1 parent 061f7a2 commit d3577c9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/com/google/devtools/build/lib/bazel/bzlmod/AttributeValuesAdapter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.google.devtools.build.lib.bazel.bzlmod;
1717

1818
import com.google.devtools.build.lib.cmdline.Label;
19+
import com.google.gson.Gson;
1920
import com.google.gson.JsonArray;
2021
import com.google.gson.JsonElement;
2122
import com.google.gson.JsonNull;
@@ -39,13 +40,16 @@
3940
/** Helps serialize/deserialize {@link AttributeValues}, which contains Starlark values. */
4041
public class AttributeValuesAdapter extends TypeAdapter<AttributeValues> {
4142

43+
private final Gson gson = new Gson();
44+
4245
@Override
4346
public void write(JsonWriter out, AttributeValues attributeValues) throws IOException {
44-
JsonObject jsonObject = new JsonObject();
47+
out.beginObject();
4548
for (Map.Entry<String, Object> entry : attributeValues.attributes().entrySet()) {
46-
jsonObject.add(entry.getKey(), serializeObject(entry.getValue()));
49+
out.name(entry.getKey());
50+
gson.toJson(serializeObject(entry.getValue()), out);
4751
}
48-
out.jsonValue(jsonObject.toString());
52+
out.endObject();
4953
}
5054

5155
@Override

0 commit comments

Comments
 (0)