From 0efae7db7b5870246f1e294a5fedaa69e9c90331 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Feb 2024 15:40:02 +0200 Subject: Add json_map and json_set buildfile value types These expose the std::map and std::set types to buildfiles. New functions: $size() $size() $keys() Note that the $keys() function returns the list of map key as a json array. For example: m = [json_map] 2@([json] a@1 b@2) 1@([json] 1 2) s = [json_set] ([json] x@1 y@2) ([json] a@1 b@2) print ($m[2][b]) # 2 print ($s[([json] y@2 x@1)]) # true --- tests/function/json/testscript | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/function/json') diff --git a/tests/function/json/testscript b/tests/function/json/testscript index b7134a8..54e524f 100644 --- a/tests/function/json/testscript +++ b/tests/function/json/testscript @@ -37,7 +37,7 @@ object object EOO -: size +: value-size : $* <>EOO print $value_size([json] null) @@ -244,3 +244,14 @@ EOO :1:6: info: while calling json.load() EOE } + +: size +: +{ + $* <'print $size([json_set] a b b)' >'2' : json-set + $* <'print $size([json_map] a@1 b@2 b@3)' >'2' : json-map +} + +: keys +: +$* <'print $keys([json_map] 2@([json] a@1 b@2 c@3) 1@([json] 1 2 3))' >'[1,2]' -- cgit v1.1