JSON encode in bash -


is there better alternative doing:

echo "{\"error\": \"must executed using user account 'admin'.\"}" >&2; 

in bash scripts?

you try here document:

cat <<eot {"error": "must executed using user account 'admin'."} eot 

this works unless have single line containing eot in text wish cat. if that's problem, can select alternate token, e.g.

cat <<foo eot foo 

additionally, if find basic here documents resulting in unwanted expansion, e.g.

cat <<eot foo$a eot 

will try expand $a, can quote here document token stop expansion:

cat <<'eot' foo$a eot 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -