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