question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The output JSON is not valid JSON,

See original GitHub issue

Describe the bug The output JSON is not valid JSON, the separator should be a comma, but its no there also its not enclosed by [ ]

{"total":"6.7Gi","used":"1.9Gi","free":"2.4Gi","available":"62Mi"}
{"total":"2.0Gi","used":"0B","free":"2.0Gi"}

To Reproduce Steps to reproduce the behavior:

  1. Issued pxi command. free -mhw | pxi '(['','total', 'used','free','available'])=>({total,used,free,available})' --from ssv --to json
  2. Error thrown or unexpected behavior.
{"total":"6.7Gi","used":"1.9Gi","free":"2.4Gi","available":"62Mi"}
{"total":"2.0Gi","used":"0B","free":"2.0Gi"}

Expected behavior

[
{"total":"6.7Gi","used":"1.9Gi","free":"2.4Gi","available":"62Mi"},
{"total":"2.0Gi","used":"0B","free":"2.0Gi"}
]

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Version (pxi --version): 0.37.0

Additional context

I think comma-separated JSON output should be the default mode.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
OptimBrocommented, Apr 7, 2022

Maybe you can achieve what you are looking for with the following?

free -mhw |
pxi "([total, used, free, available]) => ({total, used, free, available})" --from ssv |
awk '{print $0 ","}' |
sed '$ s/.$//' |
cat <(echo "[") - <(echo "]")

awk adds commas, sed removes the last comma, cat surrounds the stream with brackets.

Thank you so much ^^, really appreciate it.

1reaction
Yordcommented, Apr 7, 2022

Thanks for creating this magical stuff, I liked the way I can get and format the output of commands like dh, ls etc 👌😍

🙏 Thank you, I appreciate that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix “The Response Is Not a Valid JSON ... - iThemes
Top 5 Issues Behind “The response is not a valid JSON response” Error and How to Address Them · Incorrect WordPress Site Address...
Read more >
How to Fix "Updating Failed. The Response is Not a Valid ...
The JSON response error could be appearing because your website addresses on the Settings page are not configured properly. To set things right, ......
Read more >
How to Fix The Invalid JSON Error in WordPress (Beginner's ...
How to Fix The Invalid JSON Error in WordPress (Beginner's Guide) · 1. Check WordPress URLs in Settings · 2. Fix WordPress Permalink...
Read more >
6 Fixes for "the response is not a valid JSON response" Error in
1. Reset the permalinks ... Before you try anything else, you should try resetting your permalinks to resolve the invalid JSON response error....
Read more >
How to Fix the Invalid JSON Error in WordPress? - Rank Math
How To Fix 'Updating Failed. The Response is Not a Valid JSON Response' Error · Check the URL Settings of the WordPress Site...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found