Tmap

TMap is a commandline / elixir library for transforming map (json) objects

You can add, rename, remove keys, replace values using regex expressions.

See the source code (sample_rules_tyre.json, lib/plugins/.ex and test/exs) files for features.

New features are added as plugins. The available plugins are:

Installation

The package is available in Hex and can be installed by adding tmap to your list of dependencies in mix.exs:

def deps do
  [
    {:tmap, "~> 20.12.25"}
  ]
end

Usage as library

See test files for usage samples.

Usage as command line

Remember to built the exe file with

mix escript.build

cat myjsonfile.json | tmap --rules-file sample_rules_type.json

tmap --rules-file sample_rules_type.json --input-file myjsonfile.json --output-file newjsonfile.json

cat myjsonfile.json | tmap --rules '[{"action": "KeysSelect", "keys": ["brand"]}]'

cat a.json | tmap --rules '[{"action": "ValueRegexReplace", "replace_with": "", "keys": ["voc"], "value_regex": "[0-9]"}]'