diff --git a/data/testing/asteriskArray/asteriskArray.fix b/data/testing/asteriskArray/asteriskArray.fix new file mode 100644 index 0000000..aee27d6 --- /dev/null +++ b/data/testing/asteriskArray/asteriskArray.fix @@ -0,0 +1,26 @@ +# -------These work +set_array("TEST_TWO[]") +copy_field("test[].*", "TEST_TWO[].$append") +set_array("TEST_3[]") +copy_field("test[].*", "TEST_THREE[].$append") + +replace_all("test[].*", "o", "__") +append("test[].*", " is cool") +replace_all("coll[].*.a", "o", "__") +prepend("coll[].*.a", "HELLO ") + +lookup("animals[].*.Aanimal", "data/testing/asteriskArray/mapfile.tsv", "sep_char":"\t") + +# ----------These do nothing +set_array("TEST_4[]") +copy_field("nestedTest[].*.test[].*", "TEST_4[].$append") +split_field("others[].*.tools","--") +sort_field("OTHERS[].*.dnimals[]") + +# ----------These break: +# reverse("TEST_3[].*") +# reverse("ANIMALS[].*") + +# sum("OTHERS[].*.dumbers[]") + +# rename("OTHERS[].*", "d", "XY") diff --git a/data/testing/asteriskArray/asteriskArray.flux b/data/testing/asteriskArray/asteriskArray.flux new file mode 100644 index 0000000..643eb09 --- /dev/null +++ b/data/testing/asteriskArray/asteriskArray.flux @@ -0,0 +1,8 @@ +FLUX_DIR + "test.json" +|open-file +| as-records +| decode-json +| fix(FLUX_DIR + "asteriskArray.fix") +| encode-json(prettyPrinting="True") +| write(FLUX_DIR + "result.json") +; diff --git a/data/testing/asteriskArray/expected.json b/data/testing/asteriskArray/expected.json new file mode 100644 index 0000000..5ea9347 --- /dev/null +++ b/data/testing/asteriskArray/expected.json @@ -0,0 +1,44 @@ +{ + "test" : [ "One is cool", "Tw__ is cool", "Three is cool" ], + "coll" : [ { + "a" : "HELLO D__g" + }, { + "a" : "HELLO Ape" + }, { + "a" : "HELLO Giraffe" + }, { + "a" : "HELLO Cr__c__dile" + } ], + "others" : [ { + "name" : "Jake", + "animal" : "dog", + "tools" : [ + {"1": "magic", + "2": "arms", + "3": "shapeShifting"} + ] + }, { + "name" : "Finn", + "animal" : "human", + "tools" : [ + {"1": "sword", + "2": "anotherSword", + "3": "arm"} + ] + } ], + "OTHERS" : [ { + "name" : "Jake", + "dnimals" : [ "cat", "dog", "zebra" ], + "dumbers" : [ "20" ] + } ], + "animals" : [ { + "name" : "Jake", + "Aanimal" : "mammal" + }, { + "name" : "Blacky", + "Aanimal" : "bird" + } ], + "TEST_TWO" : [ "One", "Two", "Three" ], + "TEST_3" : [ "enO", "owT", "eerhT" ], + "Test_4": [ "One", "Two", "Three", "4", "5", "6"] +} diff --git a/data/testing/asteriskArray/mapfile.tsv b/data/testing/asteriskArray/mapfile.tsv new file mode 100644 index 0000000..c9186ed --- /dev/null +++ b/data/testing/asteriskArray/mapfile.tsv @@ -0,0 +1,6 @@ +dog mammal +cat mammal +parrot bird +shark fish +dragon ficational animal +unicorn ficational animal diff --git a/data/testing/asteriskArray/result.json b/data/testing/asteriskArray/result.json new file mode 100644 index 0000000..177f5a3 --- /dev/null +++ b/data/testing/asteriskArray/result.json @@ -0,0 +1,53 @@ +{ + "test" : [ "One is cool", "Tw__ is cool", "Three is cool" ], + "nestedTest" : [ { + "test" : [ "One", "Two", "Three" ] + }, { + "test" : [ "4", "5", "6" ] + } ], + "coll" : [ { + "a" : "HELLO D__g" + }, { + "a" : "HELLO Ape" + }, { + "a" : "HELLO Giraffe" + }, { + "a" : "HELLO Cr__c__dile" + } ], + "others" : [ { + "name" : "Jake", + "animal" : "dog", + "tools" : "magic--arms--shapeShifting" + }, { + "name" : "Finn", + "animal" : "human", + "tools" : "sword--anotherSword--arm" + } ], + "OTHERS" : [ { + "name" : "Jake", + "dnimals" : [ "dog", "zebra", "cat" ], + "dumbers" : [ "7", "2", "1", "10" ] + } ], + "animals" : [ { + "name" : "Jake", + "Aanimal" : "mammal" + }, { + "name" : "Blacky", + "Aanimal" : "bird" + } ], + "ANIMALS" : [ { + "Aanimal" : "dog", + "name" : "Jake" + }, { + "Aanimal" : "parrot", + "name" : "Blacky" + } ], + "TEST_TWO" : [ "One", "Two", "Three" ], + "TEST_3" : [ ], + "TEST_THREE" : [ { + "1" : "One", + "2" : "Two", + "3" : "Three" + } ], + "TEST_4" : [ ] +} diff --git a/data/testing/asteriskArray/test.json b/data/testing/asteriskArray/test.json new file mode 100644 index 0000000..3c5786f --- /dev/null +++ b/data/testing/asteriskArray/test.json @@ -0,0 +1,85 @@ +{ + "test": [ + "One", + "Two", + "Three" + ], + "nestedTest": [ + { + "test": [ + "One", + "Two", + "Three" + ] + }, + { + "test": [ + "4", + "5", + "6" + ] + } + ], + "coll": [ + { + "a": "Dog" + }, + { + "a": "Ape" + }, + { + "a": "Giraffe" + }, + { + "a": "Crocodile" + } + ], + "others": [ + { + "name": "Jake", + "animal": "dog", + "tools": "magic--arms--shapeShifting" + }, + { + "name": "Finn", + "animal": "human", + "tools": "sword--anotherSword--arm" + } + ], + "OTHERS": [ + { + "name": "Jake", + "dnimals": [ + "dog", + "zebra", + "cat" + ], + "dumbers": [ + "7", + "2", + "1", + "10" + ] + } + ], + "animals": [ + { + "name": "Jake", + "Aanimal": "dog" + }, + { + "name": "Blacky", + "Aanimal": "parrot" + } + ], + "ANIMALS": [ + { + "Aanimal": "dog", + "name": "Jake" + }, + { + "Aanimal": "parrot", + "name": "Blacky" + } + ] +} \ No newline at end of file