convert

Converts data types of values

The types available

  • num
  • str
  • bool

Duration and memory units are available as well

  • kiB (also K) units of 1024
  • MiB (also M)
  • GiB (also G)
  • KB (units of 1000)
  • MB
  • GB
  • s seconds
  • ms (milliseconds)
  • us (microseconds)

Example

input:

{"value":"1GiB"}

action:

convert:
  - value: KB

output:

{"value":1073741.824}

Example

input:

{"value":"1GiB"}

action:

convert:
  - value: KiB

output:

{"value":1048576}

Example

input:

{"s":1,"number":"1"}

action:

convert:
  - number: num

output:

{"s":1,"number":1}

Example: If incoming data has no unit, you can use special from/to conversion

input:

{"time": "500", "memory": 1}

action:

convert:
  - time: ms/s  # from millis to secs
  - memory: G/M # from GiB to MiB

output:

{"time":0.5,"memory":1024}

Example: There is a special type called split

This takes values separated by either commas or spaces and make them into a JSON array.

input:

{"data":"1 two 3"}

action:

convert:
  - data: split

output:

{"data":[1,"two",3]}
Field NameDescriptionTypeDefault
fieldsPairs of file names and types they should be converted to--
autoAllows auto-conversion, which helps when fields to be converted are numerous--

fields

Pairs of file names and types they should be converted to

Use this to exclude fields that would not convert correctly using auto

Example

input:

{"b":0,"number":"1"}

action:

convert:
  auto: true
  fields:
    - b: bool

output:

{"b":false,"number":1}

auto

Allows auto-conversion, which helps when fields to be converted are numerous

Example

input:

{"text":"one","number":"1"}

action:

convert:
  auto: true

output:

{"text":"one","number":1}