sgreben / jp

dead simple terminal plots from JSON data. single binary, no dependencies. linux, osx, windows.
MIT License
1.32k stars 33 forks source link

Question: JSONLines support #17

Closed tsenart closed 6 years ago

tsenart commented 6 years ago

Thanks for this project. It looks very promising and match made in heaven for integration with Vegeta in ways similar to these: https://github.com/tsenart/vegeta#usage-real-time-analysis

Vegeta can dump results in JSONLines format and I couldn't figure out if JSONPath supports this.

A current workaround is to use a rather difficult jq expression to convert JSONLines to JSON: jq -nr '"[", try (input|tojson, repeat(",\n\(input|tojson)")), "]"'

sgreben commented 6 years ago

Hey, thanks for opening the issue! I'll just add JSONLines support as another alternative to CSV and JSON. Until that's done, you might want to use the simpler jq -s to collect JSONLines into an array, e.g.:

$ echo 1 2 3  '{"a":123}' | jq -s
[
  1,
  2,
  3,
  {
    "a": 123
  }
]
tsenart commented 6 years ago

@sgreben: Nice!

tsenart commented 6 years ago

To be honest, with such a simple jq command at hand (jq -s), I don't know if it's worth it to implement it directly in jp. I'd just clearly document how to work with JSONLines using that jq command.

sgreben commented 6 years ago

@tsenart yeah, that makes sense. I've added a JSONLines section to the README now.

I am thinking about significantly re-designing the CLI, perhaps that will be a better time to add "native" JSONLines support. I'd close the issue for now - is that ok with you?

tsenart commented 6 years ago

SGTM