Skip to content

Commit

Permalink
[6.4.0] Bzlmod lockfile: fix pretty printing for attributes (#19691)
Browse files Browse the repository at this point in the history
This PR contains 1 commit(s).

1)RELNOTES:
Commit
d3577c9

PiperOrigin-RevId: 569510142
Change-Id: I46f3db411c720b79f3474da67a5b1614a0b7815f

Co-authored-by: Googler <pcloudy@google.com>
  • Loading branch information
bazel-io and meteorcloudy authored Oct 2, 2023
1 parent c86941f commit 48bee94
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.devtools.build.lib.bazel.bzlmod;

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

private final Gson gson = new Gson();

@Override
public void write(JsonWriter out, AttributeValues attributeValues) throws IOException {
JsonObject jsonObject = new JsonObject();
out.beginObject();
for (Map.Entry<String, Object> entry : attributeValues.attributes().entrySet()) {
jsonObject.add(entry.getKey(), serializeObject(entry.getValue()));
out.name(entry.getKey());
gson.toJson(serializeObject(entry.getValue()), out);
}
out.jsonValue(jsonObject.toString());
out.endObject();
}

@Override
Expand Down

0 comments on commit 48bee94

Please sign in to comment.