mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-16 02:07:08 +00:00
fix: allow different type inside array for GetJsonKey
builtin fct
This commit is contained in:
parent
3a4c614fc1
commit
1cb61d5609
@ -76,10 +76,12 @@ public class GetJsonKey extends SimpleReturnFunction {
|
|||||||
final JsonArray array = (JsonArray) json;
|
final JsonArray array = (JsonArray) json;
|
||||||
final JsonArray result = new JsonArray();
|
final JsonArray result = new JsonArray();
|
||||||
for (JsonValue tmp : array) {
|
for (JsonValue tmp : array) {
|
||||||
|
if (tmp.isObject()) {
|
||||||
final JsonObject object = (JsonObject) tmp;
|
final JsonObject object = (JsonObject) tmp;
|
||||||
for (String key : object.names())
|
for (String key : object.names())
|
||||||
result.add(key);
|
result.add(key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TValue.fromJson(result);
|
return TValue.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ class GetJsonKeyTest {
|
|||||||
" '{\"a\":\"abc\"}' , [\"a\"]",
|
" '{\"a\":\"abc\"}' , [\"a\"]",
|
||||||
" '[{\"a\":[1, 2]}, {\"b\":[3, 4]}]' , '[\"a\",\"b\"]'",
|
" '[{\"a\":[1, 2]}, {\"b\":[3, 4]}]' , '[\"a\",\"b\"]'",
|
||||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '[\"a\",\"b\",\"b\"]'",
|
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '[\"a\",\"b\",\"b\"]'",
|
||||||
// TODO: Manage Array with different type inside
|
// DONE: Manage Array with different type inside
|
||||||
// Ref.:
|
// Ref.:
|
||||||
// - https://datatracker.ietf.org/doc/html/rfc8259#section-5
|
// - https://datatracker.ietf.org/doc/html/rfc8259#section-5
|
||||||
// - https://json-schema.org/understanding-json-schema/reference/array.html
|
// - https://json-schema.org/understanding-json-schema/reference/array.html
|
||||||
//" '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]",
|
" '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]",
|
||||||
})
|
})
|
||||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||||
|
Loading…
Reference in New Issue
Block a user