From 8fdf20fd84ec88d8f8a250f56d2b4d29ba946392 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 30 Sep 2018 01:08:51 +0100 Subject: Expansions: extract methods for JSON objects and arrays. Bug 2282 --- test/scripts/0000-Basic/0002 | 21 +++++++++++++++++++++ test/stdout/0002 | 9 +++++++++ 2 files changed, 30 insertions(+) (limited to 'test') diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002 index 27bf70806..65ce40b6a 100644 --- a/test/scripts/0000-Basic/0002 +++ b/test/scripts/0000-Basic/0002 @@ -874,6 +874,27 @@ ${if ={1}{1} {true}{${if ={1}{1} {true}{${if ={1}{1}{true}fail}}}}} ${env {USER}} ${env {NO_SUCH_VARIABLE} {oops, success} {correct}} +# JSON + +${extract json {Url} \ + { \{ \"Url\": \"http://www.example.com/image/481989943\",\ + \"Height\": 125,\ + \"Width\": 100\ + \} \ + } \ + } +${extract json {Width} \ + { \{ \"Url\": \"http://www.example.com/image/481989943\",\ + \"Height\": 125,\ + \"Width\": 100\ + \} \ + } \ + } +${extract json {2} {[116, 943, 234, 38793]} } +${extract json {2} {${extract json{IDs} {\{"other":"foo", "IDs": [116, 943, 234]\} }}} } + +${extract json {seconds} { \{"hours":0, "mins":0, "seconds":59\} }} +${extract json {seconds} {${extract json {2} { ["irrelevant", \{"hours":0, "mins":0, "seconds":59\}] }}}} **** # Test "escape" with print_topbitchars exim -be -DPTBC=print_topbitchars diff --git a/test/stdout/0002 b/test/stdout/0002 index 20f418360..a8d1361d1 100644 --- a/test/stdout/0002 +++ b/test/stdout/0002 @@ -829,6 +829,15 @@ xyz > CALLER > correct > +> # JSON +> +> "http://www.example.com/image/481989943" +> 100 +> 943 +> 943 +> +> 59 +> 59 > > escape: B7·F2ò > -- cgit v1.2.3