File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/main/java/com/google/devtools/build/lib/bazel/bzlmod Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1616package com .google .devtools .build .lib .bazel .bzlmod ;
1717
1818import com .google .devtools .build .lib .cmdline .Label ;
19+ import com .google .gson .Gson ;
1920import com .google .gson .JsonArray ;
2021import com .google .gson .JsonElement ;
2122import com .google .gson .JsonNull ;
3940/** Helps serialize/deserialize {@link AttributeValues}, which contains Starlark values. */
4041public 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
You can’t perform that action at this time.
0 commit comments