ropensci / jqr

R interface to jq
https://docs.ropensci.org/jqr
Other
143 stars 13 forks source link

"." filter and pretty printing. #27

Closed smbache closed 8 years ago

smbache commented 8 years ago

From the manual:

"Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, curl."

for input {"foo":[{"bar":"baz"}]} jq with the basic . filter produces:

{
  "foo": [
    {
      "bar": "baz"
    }
  ]
}

jqr produces:

> '{"foo":[{"bar":"baz"}]}' %>% dot() %>% pretty
{"foo":[{"bar":"baz"}]}

> '{"foo":[{"bar":"baz"}]}' %>% jq(".") 
{"foo":[{"bar":"baz"}]} 

Is this a deliberate choice? I can see the usefulness og the default "prettying"...

sckott commented 8 years ago

Good point. I don't think we've thought about this, at least I haven't.

I'll have a think about it. It does probably make sense to pretty print with newlines

smbache commented 8 years ago

Mostly for consistency with the standard jq behavior. I think this is what people would expect as it's almost the first lesson in the docs for jq :)

sckott commented 8 years ago

okay, pushed a change, should behave just like jq now, via jqr::combine()

sckott commented 8 years ago

i think this is sorted now

smbache commented 8 years ago

Yes! It's good!