There are four modes for handling strings that exceed MaxLen. All examples below use MaxLen of 10 on this input:
data = "hello world, this is a long string"
Truncate (default) cuts the string to the max length:
{
"data": "hello worl"
}
Empty replaces the string with an empty string:
{
"data": ""
}
Redact replaces the string with "[redacted]":
{
"data": "[redacted]"
}
Replace uses a custom replacement string:
reader, err := luadata.TextToJSON("input", input,
luadata.WithStringTransform(10, "replace", "<too long>"),
)
{
"data": "<too long>"
}
From the CLI, use the --string-max-len and --string-mode flags:
luadata tojson --string-max-len=10 --string-mode=redact input.lua
For the replace mode, add --string-replacement:
luadata tojson --string-max-len=10 --string-mode=replace --string-replacement="<too long>" input.lua
Want more flexibility? Open the interactive converter to try any Lua input with all available options.