Newlines coming through json not working

Options
joekinley
joekinley
Community Member

My example:

echo '{"title":"FOOOOO","category":"SECURE_NOTE","fields":[{"id":".env","label":"Env File","purpose":"NOTES","section":{"id":"Production","label":"Production Section"},"type":"STRING","value":"Env Files for Project myproject"},{"type":"STRING","label":".env","value":"FOO=bar\nBAR=melfgen\nWHEE=whoop://\nTHIS=is a test","section":{"id":"Testing","label":"Testing Section"}},{"type":"STRING","label":".env","value":"FOO=otherbar\nBAR=melfgentwoo\nWHEE=whoop://production\nTHIS=is production","section":{"id":"Production","label":"Production Section"}}],"sections":[{"id":"Testing","label":"Testing Section"},{"id":"Production","label":"Production Section"}],"vault":{"id":"MYVAULTID","name":"MYVAULT"}}' | op item create -

NOTE: The vault specifics need to be changed accordingly for the test to work

Which does create the item, and the op item get back works just like I would create it in the App, BUT the newlines are not being presented in the UI. So fully automated scripting works, but it is not really human readable in the UI.
If I create the item the same way in the UI, it works with multilines, is human readable, and returns the exact same json code when exporting in the CLI. So there must be something weird happening when creating it through the OP cli.

Also, the created text fields do not allow for newlines when editing back in the UI, but the manually created ones do, so there is definitely something different going on.

So how can I create the newlines through the CLI the same way I would through the UI, as the example does not make it possible?


1Password Version: 2.16.0
Extension Version: Not Provided
OS Version: ubuntu linux
Browser:_ Not Provided

Comments

  • joekinley
    joekinley
    Community Member
    Options

    By the way, in the first field (the one with purpose=NOTES), the newline does work as expected, just not all the additional fields

  • Hi @joekinley,

    Yup, that looks like an issue somewhere between the CLI and the displayed item, I will log a ticket to get that looked at, thank you for flagging!

    Cheers,
    Amanda

This discussion has been closed.