|
19 | 19 | import java.util.Objects; |
20 | 20 |
|
21 | 21 | import org.jspecify.annotations.Nullable; |
| 22 | +import tools.jackson.databind.node.ObjectNode; |
22 | 23 |
|
23 | 24 | import org.springframework.boot.buildpack.platform.docker.type.Image; |
| 25 | +import org.springframework.boot.buildpack.platform.json.SharedJsonMapper; |
24 | 26 | import org.springframework.util.Assert; |
25 | 27 | import org.springframework.util.StringUtils; |
26 | 28 |
|
@@ -108,19 +110,15 @@ public static ImagePlatform from(Image image) { |
108 | 110 | * @return the JSON string |
109 | 111 | */ |
110 | 112 | public String toJson() { |
111 | | - StringBuilder json = new StringBuilder("{"); |
112 | | - json.append(jsonPair("os", this.os)); |
| 113 | + ObjectNode json = SharedJsonMapper.get().createObjectNode(); |
| 114 | + json.put("os", this.os); |
113 | 115 | if (StringUtils.hasText(this.architecture)) { |
114 | | - json.append(",").append(jsonPair("architecture", this.architecture)); |
| 116 | + json.put("architecture", this.architecture); |
115 | 117 | } |
116 | 118 | if (StringUtils.hasText(this.variant)) { |
117 | | - json.append(",").append(jsonPair("variant", this.variant)); |
| 119 | + json.put("variant", this.variant); |
118 | 120 | } |
119 | | - return json.append("}").toString(); |
120 | | - } |
121 | | - |
122 | | - private String jsonPair(String name, String value) { |
123 | | - return "\"%s\":\"%s\"".formatted(name, value); |
| 121 | + return json.toString(); |
124 | 122 | } |
125 | 123 |
|
126 | 124 | } |
0 commit comments