In the following MWE

echo x="1e2" | mlr --ojson cat

my intention is for miller to generate a one-element JSON array containing the object

{"x": "1e2"}

The object actually returned (within the array) is instead

{"x": 1e2}

where the value is taken as a number, I guess that as a consequence of its parsing. How can I tell miller to generate the JSON object with a string for its value rather than a number? (The rationale underlying the quotation marks around '1e2' in the MWE is precisely to highlight this intention.)

  • 1
    In echo x="1e2", do you think the output includes the quotes?
    – muru
    Jul 31, 2023 at 5:50
  • @muru: I get your point. I was only highlighting my intention to have as value a string rather than a number. Escaping the quotation marks would lead to a string value, but one including the latter (escaped) marks.
    – Marcos
    Jul 31, 2023 at 17:23

1 Answer 1


In Miller 6 you can use -S flag, which forces Miller to treat the data as strings:

echo x="1e2" | mlr --ojson -S cat

to get

  "x": "1e2"

Or you can cast it using string function

echo x="1e2" | mlr --ojson put '$x=string($x)'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .