From d0b1b5bc15a51e81c7837df964d3c19e7b78b9cb Mon Sep 17 00:00:00 2001 From: Charles Mita Date: Tue, 19 Mar 2024 15:22:23 +0100 Subject: [PATCH] Replace instances of to_json() method with json.encode(..) The to_json and to_proto methods on struct are deprecated and will be removed. The "json" and "proto" builtin modules should be used instead. This replaces instances of `foo.to_json()` with `json.encode(foo)`. --- swift/internal/compiling.bzl | 4 ++-- swift/internal/vfsoverlay.bzl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/swift/internal/compiling.bzl b/swift/internal/compiling.bzl index 676c066a9..78646768f 100644 --- a/swift/internal/compiling.bzl +++ b/swift/internal/compiling.bzl @@ -3250,13 +3250,13 @@ def _declare_multiple_outputs_and_write_output_file_map( output_map[src.path] = struct(**src_output_map) actions.write( - content = struct(**output_map).to_json(), + content = json.encode(struct(**output_map)), output = output_map_file, ) if split_derived_file_generation: actions.write( - content = struct(**derived_files_output_map).to_json(), + content = json.encode(struct(**derived_files_output_map)), output = derived_files_output_map_file, ) diff --git a/swift/internal/vfsoverlay.bzl b/swift/internal/vfsoverlay.bzl index 0eea7b9c3..9c8ea5f60 100644 --- a/swift/internal/vfsoverlay.bzl +++ b/swift/internal/vfsoverlay.bzl @@ -56,7 +56,7 @@ def write_vfsoverlay( # The YAML specification defines it has a superset of JSON, so it is safe to # use the built-in `to_json` function here. - vfsoverlay_yaml = struct(**vfsoverlay_object).to_json() + vfsoverlay_yaml = json.encode(struct(**vfsoverlay_object)) actions.write( content = vfsoverlay_yaml,