Giter VIP home page Giter VIP logo

jqr's Introduction

jqr

R-CMD-check codecov cran checks rstudio mirror downloads cran version

R interface to jq, a JSON processor http://jqlang.github.io/jq/

jqr makes it easy to process large amounts of json without having to convert from json to R, or without using regular expressions. This means that the eventual loading into R can be quicker.

Quickstart Tutorial

The jq command line examples from the jq tutorial work exactly the same in R!

library(curl)
library(jqr)
curl('https://api.github.com/repos/ropensci/jqr/commits?per_page=5') %>%
  jq('.[] | {message: .commit.message, name: .commit.committer.name}')
#> [
#>     {
#>         "message": "update cran comments and codemeta.json",
#>         "name": "Scott Chamberlain"
#>     },
#>     {
#>         "message": "change license to \"jqr authors\"",
#>         "name": "Scott Chamberlain"
#>     },
#>     {
#>         "message": "fix ci",
#>         "name": "Jeroen Ooms"
#>     },
#>     {
#>         "message": "Windows: update to libjq 1.6",
#>         "name": "Jeroen Ooms"
#>     },
#>     {
#>         "message": "Small tweak for autobrew",
#>         "name": "Jeroen Ooms"
#>     }
#> ]

Try running some of the other examples.

Installation

Binary packages for OS-X or Windows can be installed directly from CRAN:

install.packages("jqr")

Installation from source on Linux or OSX requires libjq. On Ubuntu 14.04 and 16.04 lower use libjq-dev from Launchpad:

sudo add-apt-repository -y ppa:cran/jq
sudo apt-get update -q
sudo apt-get install -y libjq-dev

More recent Debian or Ubuntu install libjq-dev directly from Universe:

sudo apt-get install -y libjq-dev

On Fedora we need jq-devel:

sudo yum install jq-devel

On CentOS / RHEL we install jq-devel via EPEL:

sudo yum install epel-release
sudo yum install jq-devel

On OS-X use jq from Homebrew:

brew install jq

On Solaris we can have libjq_dev from OpenCSW:

pkgadd -d http://get.opencsw.org/now
/opt/csw/bin/pkgutil -U
/opt/csw/bin/pkgutil -y -i libjq_dev
library(jqr)

Interfaces

low level

There's a low level interface in which you can execute jq code just as you would on the command line:

str <- '[{
    "foo": 1,
    "bar": 2
  },
  {
    "foo": 3,
    "bar": 4
  },
  {
    "foo": 5,
    "bar": 6
}]'
jq(str, ".[]")
#> [
#>     {
#>         "foo": 1,
#>         "bar": 2
#>     },
#>     {
#>         "foo": 3,
#>         "bar": 4
#>     },
#>     {
#>         "foo": 5,
#>         "bar": 6
#>     }
#> ]
jq(str, "[.[] | {name: .foo} | keys]")
#> [
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ]
#> ]

Note that we print the output to look like a valid JSON object to make it easier to look at. However, it's a simple character string or vector of strings. A trick you can do is to wrap your jq program in brackets like [.[]] instead of .[], e.g.,

jq(str, ".[]") %>% unclass
#> [1] "{\"foo\":1,\"bar\":2}" "{\"foo\":3,\"bar\":4}" "{\"foo\":5,\"bar\":6}"
# vs.
jq(str, "[.[]]") %>% unclass
#> [1] "[{\"foo\":1,\"bar\":2},{\"foo\":3,\"bar\":4},{\"foo\":5,\"bar\":6}]"

Combine many jq arguments - they are internally combined with a pipe |

(note how these are identical)

jq(str, ".[] | {name: .foo} | keys")
#> [
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ]
#> ]
jq(str, ".[]", "{name: .foo}", "keys")
#> [
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ],
#>     [
#>         "name"
#>     ]
#> ]

Also accepts many JSON inputs now

jq("[123, 456]   [77, 88, 99]", ".[]")
#> [
#>     123,
#>     456,
#>     77,
#>     88,
#>     99
#> ]
jq('{"foo": 77} {"bar": 45}', ".[]")
#> [
#>     77,
#>     45
#> ]
jq('[{"foo": 77, "stuff": "things"}] [{"bar": 45}] [{"n": 5}]', ".[] | keys")
#> [
#>     [
#>         "foo",
#>         "stuff"
#>     ],
#>     [
#>         "bar"
#>     ],
#>     [
#>         "n"
#>     ]
#> ]

# if you have jsons in a vector
jsons <- c('[{"foo": 77, "stuff": "things"}]', '[{"bar": 45}]', '[{"n": 5}]')
jq(paste0(jsons, collapse = " "), ".[]")
#> [
#>     {
#>         "foo": 77,
#>         "stuff": "things"
#>     },
#>     {
#>         "bar": 45
#>     },
#>     {
#>         "n": 5
#>     }
#> ]

high level

The other is higher level, and uses a suite of functions to construct queries. Queries are constucted, then excuted internally with jq() after the last piped command.

You don't have to use pipes though. See examples below.

Examples:

Index

x <- '[{"message": "hello", "name": "jenn"}, {"message": "world", "name": "beth"}]'
x %>% index()
#> [
#>     {
#>         "message": "hello",
#>         "name": "jenn"
#>     },
#>     {
#>         "message": "world",
#>         "name": "beth"
#>     }
#> ]

Sort

'[8,3,null,6]' %>% sortj
#> [
#>     null,
#>     3,
#>     6,
#>     8
#> ]

reverse order

'[1,2,3,4]' %>% reverse
#> [
#>     4,
#>     3,
#>     2,
#>     1
#> ]

Show the query to be used using peek()

'[1,2,3,4]' %>% reverse %>% peek
#> <jq query>
#>   query: reverse

get multiple outputs for array w/ > 1 element

x <- '{"user":"jqlang","titles":["JQ Primer", "More JQ"]}'
jq(x, '{user, title: .titles[]}')
#> [
#>     {
#>         "user": "jqlang",
#>         "title": "JQ Primer"
#>     },
#>     {
#>         "user": "jqlang",
#>         "title": "More JQ"
#>     }
#> ]
x %>% index()
#> [
#>     "jqlang",
#>     [
#>         "JQ Primer",
#>         "More JQ"
#>     ]
#> ]
x %>% build_object(user, title = `.titles[]`)
#> [
#>     {
#>         "user": "jqlang",
#>         "title": "JQ Primer"
#>     },
#>     {
#>         "user": "jqlang",
#>         "title": "More JQ"
#>     }
#> ]
jq(x, '{user, title: .titles[]}') %>% jsonlite::toJSON() %>% jsonlite::validate()
#> [1] TRUE

string operations

join

'["a","b,c,d","e"]' %>% join
#> "a, b,c,d, e"
'["a","b,c,d","e"]' %>% join(`;`)
#> "a; b,c,d; e"

ltrimstr

'["fo", "foo", "barfoo", "foobar", "afoo"]' %>% index() %>% ltrimstr(foo)
#> [
#>     "fo",
#>     "",
#>     "barfoo",
#>     "bar",
#>     "afoo"
#> ]

rtrimstr

'["fo", "foo", "barfoo", "foobar", "foob"]' %>% index() %>% rtrimstr(foo)
#> [
#>     "fo",
#>     "",
#>     "bar",
#>     "foobar",
#>     "foob"
#> ]

startswith

'["fo", "foo", "barfoo", "foobar", "barfoob"]' %>% index %>% startswith(foo)
#> [
#>     false,
#>     true,
#>     false,
#>     true,
#>     false
#> ]
'["fo", "foo"] ["barfoo", "foobar", "barfoob"]' %>% index %>% startswith(foo)
#> [
#>     false,
#>     true,
#>     false,
#>     true,
#>     false
#> ]

endswith

'["fo", "foo", "barfoo", "foobar", "barfoob"]' %>% index %>% endswith(foo)
#> [
#>     false,
#>     true,
#>     true,
#>     false,
#>     false
#> ]

tojson, fromjson, tostring

'[1, "foo", ["foo"]]' %>% index
#> [
#>     1,
#>     "foo",
#>     [
#>         "foo"
#>     ]
#> ]
'[1, "foo", ["foo"]]' %>% index %>% tostring
#> [
#>     "1",
#>     "foo",
#>     "[\"foo\"]"
#> ]
'[1, "foo", ["foo"]]' %>% index %>% tojson
#> [
#>     "1",
#>     "\"foo\"",
#>     "[\"foo\"]"
#> ]
'[1, "foo", ["foo"]]' %>% index %>% tojson %>% fromjson
#> [
#>     1,
#>     "foo",
#>     [
#>         "foo"
#>     ]
#> ]

contains

'"foobar"' %>% contains("bar")
#> true

unique

'[1,2,5,3,5,3,1,3]' %>% uniquej
#> [
#>     1,
#>     2,
#>     3,
#>     5
#> ]

filter

With filtering via select() you can use various operators, like ==, &&, ||. We translate these internally for you to what jq wants to see (==, and, or).

Simple, one condition

'{"foo": 4, "bar": 7}' %>% select(.foo == 4)
#> {
#>     "foo": 4,
#>     "bar": 7
#> }

More complicated. Combine more than one condition; combine each individual filtering task in parentheses

x <- '{"foo": 4, "bar": 2} {"foo": 5, "bar": 4} {"foo": 8, "bar": 12}'
x %>% select((.foo < 6) && (.bar > 3))
#> {
#>     "foo": 5,
#>     "bar": 4
#> }
x %>% select((.foo < 6) || (.bar > 3))
#> [
#>     {
#>         "foo": 4,
#>         "bar": 2
#>     },
#>     {
#>         "foo": 5,
#>         "bar": 4
#>     },
#>     {
#>         "foo": 8,
#>         "bar": 12
#>     }
#> ]

types

get type information for each element

'[0, false, [], {}, null, "hello"]' %>% types
#> [
#>     "number",
#>     "boolean",
#>     "array",
#>     "object",
#>     "null",
#>     "string"
#> ]
'[0, false, [], {}, null, "hello", true, [1,2,3]]' %>% types
#> [
#>     "number",
#>     "boolean",
#>     "array",
#>     "object",
#>     "null",
#>     "string",
#>     "boolean",
#>     "array"
#> ]

select elements by type

'[0, false, [], {}, null, "hello"]' %>% index() %>% type(booleans)
#> false

key operations

get keys

str <- '{"foo": 5, "bar": 7}'
str %>% keys()
#> [
#>     "bar",
#>     "foo"
#> ]

delete by key name

str %>% del(bar)
#> {
#>     "foo": 5
#> }

check for key existence

str3 <- '[[0,1], ["a","b","c"]]'
str3 %>% haskey(2)
#> [
#>     false,
#>     true
#> ]
str3 %>% haskey(1,2)
#> [
#>     true,
#>     false,
#>     true,
#>     true
#> ]

Build an object, selecting variables by name, and rename

'{"foo": 5, "bar": 7}' %>% build_object(a = .foo)
#> {
#>     "a": 5
#> }

More complicated build_object(), using the included dataset commits

commits %>%
  index() %>%
  build_object(sha = .sha, name = .commit.committer.name)
#> [
#>     {
#>         "sha": [
#>             "110e009996e1359d25b8e99e71f83b96e5870790"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "a50e548cc5313c187483bc8fb1b95e1798e8ef65"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "4b258f7d31b34ff5d45fba431169e7fd4c995283"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "d1cb8ee0ad3ddf03a37394bfa899cfd3ddd007c5"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     }
#> ]

Maths

'{"a": 7}' %>%  do(.a + 1)
#> 8
'{"a": [1,2], "b": [3,4]}' %>%  do(.a + .b)
#> [
#>     1,
#>     2,
#>     3,
#>     4
#> ]
'{"a": [1,2], "b": [3,4]}' %>%  do(.a - .b)
#> [
#>     1,
#>     2
#> ]
'{"a": 3}' %>%  do(4 - .a)
#> 1
'["xml", "yaml", "json"]' %>%  do('. - ["xml", "yaml"]')
#> ". - [\"xml\", \"yaml\"]"
'5' %>%  do(10 / . * 3)
#> 6

comparisons

'[5,4,2,7]' %>% index() %>% do(. < 4)
#> [
#>     false,
#>     false,
#>     true,
#>     false
#> ]
'[5,4,2,7]' %>% index() %>% do(. > 4)
#> [
#>     true,
#>     false,
#>     false,
#>     true
#> ]
'[5,4,2,7]' %>% index() %>% do(. <= 4)
#> [
#>     false,
#>     true,
#>     true,
#>     false
#> ]
'[5,4,2,7]' %>% index() %>% do(. >= 4)
#> [
#>     true,
#>     true,
#>     false,
#>     true
#> ]
'[5,4,2,7]' %>% index() %>% do(. == 4)
#> [
#>     false,
#>     true,
#>     false,
#>     false
#> ]
'[5,4,2,7]' %>% index() %>% do(. != 4)
#> [
#>     true,
#>     false,
#>     true,
#>     true
#> ]

length

'[[1,2], "string", {"a":2}, null]' %>% index %>% lengthj
#> [
#>     2,
#>     6,
#>     1,
#>     0
#> ]

sqrt

'9' %>% sqrtj
#> 3

floor

'3.14159' %>% floorj
#> 3

find minimum

'[5,4,2,7]' %>% minj
#> 2
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% minj
#> {
#>     "foo": 2,
#>     "bar": 3
#> }
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% minj(foo)
#> {
#>     "foo": 1,
#>     "bar": 14
#> }
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% minj(bar)
#> {
#>     "foo": 2,
#>     "bar": 3
#> }

find maximum

'[5,4,2,7]' %>% maxj
#> 7
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% maxj
#> {
#>     "foo": 1,
#>     "bar": 14
#> }
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% maxj(foo)
#> {
#>     "foo": 2,
#>     "bar": 3
#> }
'[{"foo":1, "bar":14}, {"foo":2, "bar":3}]' %>% maxj(bar)
#> {
#>     "foo": 1,
#>     "bar": 14
#> }

Combine into valid JSON

jq sometimes creates pieces of JSON that are valid in themselves, but together are not. combine() is a way to make valid JSON.

This outputs a few pieces of JSON

(x <- commits %>%
  index() %>%
  build_object(sha = .sha, name = .commit.committer.name))
#> [
#>     {
#>         "sha": [
#>             "110e009996e1359d25b8e99e71f83b96e5870790"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "a50e548cc5313c187483bc8fb1b95e1798e8ef65"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "4b258f7d31b34ff5d45fba431169e7fd4c995283"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "d1cb8ee0ad3ddf03a37394bfa899cfd3ddd007c5"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     }
#> ]

Use combine() to put them together.

combine(x)
#> [
#>     {
#>         "sha": [
#>             "110e009996e1359d25b8e99e71f83b96e5870790"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "a50e548cc5313c187483bc8fb1b95e1798e8ef65"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "4b258f7d31b34ff5d45fba431169e7fd4c995283"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     },
#>     {
#>         "sha": [
#>             "d1cb8ee0ad3ddf03a37394bfa899cfd3ddd007c5"
#>         ],
#>         "name": [
#>             "Nicolas Williams"
#>         ]
#>     }
#> ]

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for jqr in R doing citation(package = 'jqr')
  • Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rofooter

jqr's People

Contributors

davharris avatar eitsupi avatar jeroen avatar lionel- avatar richfitz avatar sckott avatar smbache avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jqr's Issues

MacOS: No way to use PKG_LIBS_STATIC defined in configure script

Hello,

I'm trying to build a statically linked version of jqr for MacOS (like what's built on CRAN) and I'm running into an issue with configure and PKG_LIBS used in compilation.

First I brew install jq, which installs oniguruma as a dependency. Then I run:

R --vanilla CMD install jqr_1.0.0.tar.gz -l /Users/jenkins/test-r-pkg-build --build --preclean

For dynamic linking (ie using .dylib), I have no problems and can compile fine. It's only when I try static linking (ie using .a files) where I run into issue.

For static linking, I remove the .dylib files for both libjq and libonig with the following:

rm -f /usr/local/opt/jq/lib/*.dylib
rm -f /usr/local/opt/oniguruma/lib/*.dylib

Then, when I build, I get the following:

* installing *source* package 'jqr' ...
** package 'jqr' successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=-I/usr/local/opt/jq/include
Using PKG_LIBS=-L/usr/local/lib -ljq
** libs
rm -f jqr.so jqr.o register.o
/usr/local/clang4/bin/clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/jq/include  -I/usr/local/include   -fPIC  -Wall -g -O2  -c jqr.c -o jqr.o
/usr/local/clang4/bin/clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/opt/jq/include  -I/usr/local/include   -fPIC  -Wall -g -O2  -c register.c -o register.o
/usr/local/clang4/bin/clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -Xlinker -v -L/usr/local/clang4/lib -L/usr/local/gfortran/lib -L/opt/X11/lib -o jqr.so jqr.o register.o -L/usr/local/lib -ljq -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
@(#)PROGRAM:ld  PROJECT:ld64-278.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
	/Library/Frameworks/R.framework/Resources/lib
	/usr/local/clang4/lib
	/usr/local/gfortran/lib
	/opt/X11/lib
	/usr/local/lib
	/usr/lib
	/usr/local/lib
Framework search paths:
	/Library/Frameworks
	/Library/Frameworks/
	/System/Library/Frameworks/
installing to /Users/jenkins/test-r-pkg-build/jqr/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for 'jqr' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/jenkins/test-r-pkg-build/jqr/libs/jqr.so':
  dlopen(/Users/jenkins/test-r-pkg-build/jqr/libs/jqr.so, 6): Symbol not found: _OnigEncodingUTF8
  Referenced from: /Users/jenkins/test-r-pkg-build/jqr/libs/jqr.so
  Expected in: flat namespace
 in /Users/jenkins/test-r-pkg-build/jqr/libs/jqr.so
Error: loading failed
Execution halted
ERROR: loading failed

The issue seems to be the fact that jqr uses PKG_LIBS=-L/usr/local/lib -ljq instead of PKG_LIBS=-L/usr/local/lib -ljq -lonig. The former is fine when you have dynamic linking because libjq.dylib is dynamically linked to libonig.dylib, so the dependency is resolved at runtime. With static linking, the compiler must know to look for and include libonig at compile time.

I was able to build a statically linked version of jqr successfully by overwriting PKG_LIBS in Makevars, but that isn't a very good solution when you're building lots of packages at once. R seems to recommend using --configure-vars as proper way to customize package builds.

Looking at https://github.com/ropensci/jqr/blob/master/configure#L15 I see you do have the flag I need in your configure script, but I don't see any reference to that variable inside the script. This seems like a bug to me.

So, my questions are:

  1. Is this the right approach statically compile jqr?
  2. Is this a bug in configure?

I'm happy to submit a PR addressing this, but I haven't written too many R packages before. I would expect a fix to include a flag like --enable-static that configure would consume to choose the right value for PKG_LIBS. Let me know what you think about this approach.

Thanks for taking the time to read my question. Appreciate any feedback you have here!

Here's the ouput of sessionInfo as well:

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.1

Execute jq() on last pipe

@smbache Curious if you know how we can sort this out.

This package wraps jq https://stedolan.github.io/jq/

We have a low level interface to execute jq commands just as you would on the cli, but also a higher level DSL, that supports piping https://github.com/ropensci/jqr#high-level

Right now, you can build up a set of jq commands with the DSL, but then at the end you execute with jq()

Know any way that we can have jq() execute on any DSL command, given that it's the last one in the chain? This seems to work in dplyr, but I can't work out how that is done

Vignette

Once the DSL exists, need a vignette.

Might be worth having material covering both the DSL and direct interface.

jq return type

It looks like the return type of a jq query is a jqson object, which is essentially a string.

I think it would be way more useful for jq to return a proper JSON object (or list from parsing the JSON, but better to leave the user in control of the simplify* options of fromJSON`).

Under the current interface, it looks like one has to convert the string to a textConnection and then parse it with jsonlite::stream_in:


str <- '[{
    "foo": 1,
    "bar": 2
  },
  {
    "foo": 3,
    "bar": 4
  },
  {
    "foo": 5,
    "bar": 6
}]'

out <- jq(str, ".[]") %>%textConnection() %>% stream_in(simplifyDataFrame=FALSE) 

str(out)

Which I think is unnecessarily cumbersome. Would be better if it was just a valid json string.

"." filter and pretty printing.

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"...

Functions to avoid in library code

* checking compiled code ... WARNING
File ‘jqr/libs/jqr.so’:
  Found ‘___stderrp’, possibly from ‘stderr’ (C)
    Objects: ‘execute.o’, ‘jv_alloc.o’, ‘jv_print.o’, ‘lexer.o’,
      ‘locfile.o’
  Found ‘___stdoutp’, possibly from ‘stdout’ (C)
    Objects: ‘jv_print.o’, ‘lexer.o’
  Found ‘_abort’, possibly from ‘abort’ (C)
    Object: ‘jv_alloc.o’
  Found ‘_exit’, possibly from ‘exit’ (C)
    Objects: ‘jq_test.o’, ‘lexer.o’
  Found ‘_printf’, possibly from ‘printf’ (C)
    Objects: ‘bytecode.o’, ‘execute.o’, ‘jq_test.o’
  Found ‘_putchar’, possibly from ‘putchar’ (C)
    Objects: ‘bytecode.o’, ‘execute.o’, ‘jq_test.o’
  Found ‘_puts’, possibly from ‘printf’ (C), ‘puts’ (C)
    Objects: ‘bytecode.o’, ‘jq_test.o’
  Found ‘_rand’, possibly from ‘rand’ (C)
    Object: ‘jq_test.o’

Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor the system RNG.

Dont pipe

Sometimes you don't want to pipe together jq commands. But right now, that's the only option when we %>% together commands, they get | together

Would be nice to have an easy way for user to say they don't want A an B separated by a pipe, but B and C they do, etc.

examples coming

Don't import all of lazyeval

Currently in R/select.R we have #' @import lazyeval; prefer lazyeval::<....> which we actually already have.

Hold off on fixing this until the DSL fixes are in.

Eliminate additional compiler warnings

jq/jv.h:41:12: warning: unused function 'jv_is_valid' [-Wunused-function]
static int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; }
jq/jv_alloc.h:11:13: warning: unused function 'jv_mem_invalidate'
      [-Wunused-function]
static void jv_mem_invalidate(void* mem, size_t n) {
            ^
jq/execute.c:68:22: warning: unused variable 'bc' [-Wunused-variable]
    struct bytecode* bc = fpnext->bc;
                     ^
jq/execute.c:193:9: warning: unused variable 'n1' [-Wunused-variable]
    int n1 = jv_array_length(jv_copy(jq->path));
        ^
jq/execute.c:195:9: warning: unused variable 'n2' [-Wunused-variable]
    int n2 = jv_array_length(jv_copy(jq->path));
        ^
In file included from jq/execute.c:12:
lexer.c:1933:16: warning: unused function 'yy_top_state' [-Wunused-function]
    static int yy_top_state  (yyscan_t yyscanner)
               ^

Ease transition between jqr and other json tools

from @cboettig feedback

wish it was easier to go back and forth between jqr and jsonlite (e.g. without needing as.character() jqr::combine() and fromJSON())

possibly could add a global setting to change output, but would have to not break anything

Make fxns for array and object construction

i don't know what i was thinking with select() - somehow I made it for constructing objects {} - so changing select() to do what its supposed to do (filtering), and new functions for array and object construction

warning with r-devel

@jeroen was about to submit to CRAN - but this warning arises with R-devel on winbuilder and I imagine they'd reject it until fixed

Found the following significant warnings:
  jq/builtin.c:1446:1: warning: string length '14820' is greater than the length '4095' ISO C99 compilers are required to support [-Woverlength-strings]
See 'd:/RCompile/CRANguest/R-devel/jqr.Rcheck/00install.out' for details.

any ideas how to fix?

pretty masks base::pretty

Giving the always tedious warning:

"The following object is masked from package:base"...

I'd rather not export a function that will clash with a base package -- can we rename?

Trailing newline needed, at least on Linux

In the print method I don't get the right number of newlines.

> '{"a": 7}' %>% do(.a + 1) %>% peek
<jq query>
  query:  .a + 1> # this would be new prompt here!

If this applies across platforms (don't have time check RN), the fix would be

> jqr:::print.jq_query
function (x, ...) 
{
    cat("<jq query>", sep = "\n")
    cat("  query: ", x)
}

The last cat call needs a "\n"; so becomes cat(sprintf("query: %s\n", x)) (note as it is it also adds an extra space too because cat does that.

cran copyrights / license fix

Thanks, we see:

You have files in your package with GPLK license and copyright holders
not declared in the Authors@R fiel. Example: file src/parser.c (GPL,
copyright holder is the FSF).

Please carefully check if your license is possible and if all copyright
holders are mentioned.

We do have a COPYING.jq file and an AUTHORS.jq file.

Including jqr sources

For eventual CRAN release, we'll need to include the jqr sources. I've held off doing that for now partly because they're big *and require some careful .gitignore editing) and partly so that the distribution requirements/obligations are met.

  • I think we need to list the jqr authors in the DESCRIPTION field - there's some advice on this somewhere in R-exts.
  • Decide whether to keep the versioned src/jq- directory. If so, try to DRY the code up (src/Makevars and bootstrap.R)
  • Make sure we never commit any generated jq files
  • Document the weird munging of the obsolete m4 macros

Multiple JSON

Support multiple JSON objects for streaming? Currently we only take the last one.

library(jqr)
jqr:::jqr("[123, 456]   [77, 88, 99]", ".[]")

A way to combine pieces?

githubcommits %>% 
    index() %>% 
    select(sha = .sha, name = .commit.committer.name) %>% 
    jq(TRUE)

gives

#> {"sha":["110e009996e1359d25b8e99e71f83b96e5870790"],"name":["Nicolas Williams"]}
#> {"sha":["7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f"],"name":["Nicolas Williams"]}
#> {"sha":["a50e548cc5313c187483bc8fb1b95e1798e8ef65"],"name":["Nicolas Williams"]}
#> {"sha":["4b258f7d31b34ff5d45fba431169e7fd4c995283"],"name":["Nicolas Williams"]}
#> {"sha":["d1cb8ee0ad3ddf03a37394bfa899cfd3ddd007c5"],"name":["Nicolas Williams"]}

Those pieces aren't valid json, each piece is, but not all together.

A convenience function to attempt to combine these pieces would be useful, e.g, take output above and pass through a function

combine(<output above>)
#> [
#>     {"sha":["110e009996e1359d25b8e99e71f83b96e5870790"],"name":["Nicolas Williams"]},
#>     {"sha":["7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f"],"name":["Nicolas Williams"]},
#>     {"sha":["a50e548cc5313c187483bc8fb1b95e1798e8ef65"],"name":["Nicolas Williams"]},
#>     {"sha":["4b258f7d31b34ff5d45fba431169e7fd4c995283"],"name":["Nicolas Williams"]},
#>     {"sha":["d1cb8ee0ad3ddf03a37394bfa899cfd3ddd007c5"],"name":["Nicolas Williams"]}
#> ]

jq should be able to take file paths or a URL as an argument

From a purely user-interface / convenience perspective, it would be nice for jq function to be able to take a file path or URL as an argument, just so that the interface is consistent with the interface of things like fromJSON, jsonld_* fns, etc.

jq() should be able to take `json` as an input type?

If you have a json object (i.e. from jsonlite::toJSON) you currently have to coerce it to a string with as.character before you can call jqr::jq on it. Seems like jqr should be able to work with json class objects directly (i.e. do that coercion to string internally, which I think is just hacking off the class since it's really already a string)

Process returned elements

The returned output from jq may not be proper json, but a sort of vector of json strings.

str <- '[
  {
    "foo": 1,
    "bar": 2
  },
  {
    "foo": 3,
    "bar": 4
  },
  {
    "foo": 5,
    "bar": 6
  }
]'

jqr(str, ".[] | {name: .foo}")
[1] "{\"name\":1}" "{\"name\":3}" "{\"name\":5}"

Process these by default I imagine, so something like

jqr_proc <- function(json, program, ...) {
  lapply(jqr(json, program), jsonlite::fromJSON, ...)
}
jqr_proc(str, ".[] | {name: .foo}")
[[1]]
[[1]]$name
[1] 1


[[2]]
[[2]]$name
[1] 3


[[3]]
[[3]]$name
[1] 5

Windows check issues

@richfitz potential issue with Windows

submitted to win-builder and the pkg does actually install on R 3.2.3 and devel, but both fail on check,

R dev

install

* installing *source* package 'jqr' ...
*** Copying jq sources from src/jq
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

g++ -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -mtune=core2            -c RcppExports.cpp -o RcppExports.o
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c builtin.c -o builtin.o
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c bytecode.c -o bytecode.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c compile.c -o compile.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c execute.c -o execute.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
g++ -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -mtune=core2            -c jqr.cpp -o jqr.o
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv.c -o jv.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_alloc.c -o jv_alloc.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_aux.c -o jv_aux.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_dtoa.c -o jv_dtoa.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_file.c -o jv_file.o
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_parse.c -o jv_parse.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_print.c -o jv_print.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_unicode.c -o jv_unicode.o
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c lexer.c -o lexer.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
lexer.c:1933:16: warning: 'yy_top_state' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c locfile.c -o locfile.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
locfile.c: In function 'locfile_locate':
locfile.c:47:20: warning: 'startline' may be used uninitialized in this function [-Wuninitialized]
locfile.c:55:7: note: 'startline' was declared here
gcc -m64 -I"D:/RCompile/recent/R/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.3/BH/include" -I"d:/RCompile/CRANpkg/lib/3.3/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c parser.c -o parser.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
g++ -m64 -shared -s -static-libgcc -o jqr.dll tmp.def RcppExports.o builtin.o bytecode.o compile.o execute.o jqr.o jv.o jv_alloc.o jv_aux.o jv_dtoa.o jv_file.o jv_parse.o jv_print.o jv_unicode.o lexer.o locfile.o parser.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LD:/RCompile/recent/R/bin/x64 -lR
installing to d:/RCompile/CRANguest/R-devel/lib/jqr/libs/x64
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* MD5 sums
packaged installation of 'jqr' as jqr_0.1.9.9910.zip
* DONE (jqr)

check

* using log directory 'd:/RCompile/CRANguest/R-devel/jqr.Rcheck'
* using R Under development (unstable) (2016-02-07 r70118)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'jqr/DESCRIPTION' ... OK
* this is package 'jqr' version '0.1.9.9910'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Scott Chamberlain <[email protected]>'

New submission

Version contains large components (0.1.9.9910)

License components with restrictions and base license permitting such:
  MIT + file LICENSE
File 'LICENSE':
  YEAR: 2016
  COPYRIGHT HOLDER: Richard G. FitzJohn

Possibly mis-spelled words in DESCRIPTION:
  JSON (2:27, 3:31)
  jq (3:25)
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'jqr' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking 'build' directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* loading checks for arch 'i386'
** checking whether the package can be loaded ... ERROR
Loading this package had a fatal error status code 1
Loading log:
Error: package 'jqr' is not installed for 'arch = i386'
Execution halted
** DONE
Status: 1 ERROR, 1 NOTE

R 3.2.3

install

* installing *source* package 'jqr' ...
*** Copying jq sources from src/jq
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

g++ -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -mtune=core2            -c RcppExports.cpp -o RcppExports.o
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c builtin.c -o builtin.o
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c bytecode.c -o bytecode.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c compile.c -o compile.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c execute.c -o execute.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
g++ -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"     -O3 -Wall  -mtune=core2            -c jqr.cpp -o jqr.o
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv.c -o jv.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_alloc.c -o jv_alloc.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_aux.c -o jv_aux.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_dtoa.c -o jv_dtoa.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_file.c -o jv_file.o
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_parse.c -o jv_parse.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_print.c -o jv_print.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c jv_unicode.c -o jv_unicode.o
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c lexer.c -o lexer.o
jq/jv.h:41:12: warning: 'jv_is_valid' defined but not used [-Wunused-function]
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
lexer.c:1933:16: warning: 'yy_top_state' defined but not used [-Wunused-function]
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c locfile.c -o locfile.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
locfile.c: In function 'locfile_locate':
locfile.c:47:20: warning: 'startline' may be used uninitialized in this function [-Wuninitialized]
locfile.c:55:7: note: 'startline' was declared here
gcc -m64 -I"D:/RCompile/recent/R-3.2.3p/include"         -Ijq   -I"d:/RCompile/CRANpkg/lib/3.2/BH/include" -I"d:/RCompile/CRANpkg/lib/3.2/Rcpp/include" -I"d:/RCompile/r-compiling/local/local323/include"  -Ijq   -O2 -Wall  -std=gnu99 -mtune=core2 -c parser.c -o parser.o
jq/jv_alloc.h:11:13: warning: 'jv_mem_invalidate' defined but not used [-Wunused-function]
g++ -m64 -shared -s -static-libgcc -o jqr.dll tmp.def RcppExports.o builtin.o bytecode.o compile.o execute.o jqr.o jv.o jv_alloc.o jv_aux.o jv_dtoa.o jv_file.o jv_parse.o jv_print.o jv_unicode.o lexer.o locfile.o parser.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LD:/RCompile/recent/R-3.2.3p/bin/x64 -lR
installing to d:/RCompile/CRANguest/R-release/lib/jqr/libs/x64
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* MD5 sums
packaged installation of 'jqr' as jqr_0.1.9.9910.zip
* DONE (jqr)

check

* using log directory 'd:/RCompile/CRANguest/R-release/jqr.Rcheck'
* using R version 3.2.3 Patched (2016-02-04 r70085)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'jqr/DESCRIPTION' ... OK
* this is package 'jqr' version '0.1.9.9910'
* checking CRAN incoming feasibility ... NOTE
Maintainer: 'Scott Chamberlain <[email protected]>'
New submission

License components with restrictions and base license permitting such:
  MIT + file LICENSE
File 'LICENSE':
  YEAR: 2016
  COPYRIGHT HOLDER: Richard G. FitzJohn

Possibly mis-spelled words in DESCRIPTION:
  JSON (2:27, 3:31)
  jq (3:25)

The Title field should be in title case, current version then in title case:
'Client for 'jq', a JSON Processor'
'Client for 'Jq', a JSON Processor'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'jqr' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking 'build' directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* loading checks for arch 'i386'
** checking whether the package can be loaded ... ERROR
Loading this package had a fatal error status code 1
Loading log:
Error: package 'jqr' is not installed for 'arch = i386'
Execution halted
** DONE
Status: 1 ERROR, 1 NOTE

Installs with I think the same warnings as above on a windows VM locally, and functions all work fine. Any ideas

is needs importing from methods or replacing with inherits

On appveyor

* checking R code for possible problems ... NOTE 
combine: no visible global function definition for 'is'
flags: no visible global function definition for 'is'
get_expr: no visible global function definition for 'is'
peek: no visible global function definition for 'is'
tryargs: no visible global function definition for 'is'
Undefined global functions or variables:
  is
Consider adding
  importFrom("methods", "is")
to your NAMESPACE file (and ensure that your DESCRIPTION Imports field
contains 'methods').
* checking Rd files ... OK
* checking Rd metadata ... OK

I don't see this locally so it's either an R version change or a check switch. Given methods seems to mostly exist to troll package developers, can we switch these over to inherits?

Read from connection

It would be nice to be able to run a jq pipe from a connection (such as a URL, file or fifo), so that one can avoid loading all the JSON into memory.

I note that jq 1.5 has additional streaming options, including allows for to output in ndjson format, which means that one would be able to run JQ on large JSON, and pipe it to jsonlite::stream_in.

DSL `select` doesn't handle operators other than assignment `=`

e.g.,

'[{"foo": 5, "bar": 7}, {"foo": 4, "bar": 7}]' %>% index() %>% select(.foo == 4)
#> Error: jq: error: syntax error, unexpected '(', expecting '}' (Unix shell quoting issues?) at <top-level>, line 1:
#> .[] | {c("==", ".foo", "4")}

so we're clearly not treating the == as we should - see logic in do() method

lq: list query

idea from @cboettig

AFAICT idea is just to make it easy to do the stuff we can do with jq on JSON but with R lists.

is that as easy as jsonlite::toJSON, then apply any jq commands?

cran check issues

got email from cran

Please correct all the issues (including the memory-access ones) ASAP.

https://cran.r-project.org/web/checks/check_results_jqr.html

The only platforms with errors are Solaris sparc https://www.r-project.org/nosvn/R.check/r-patched-solaris-sparc/jqr-00check.html and Solaris x86 https://www.r-project.org/nosvn/R.check/r-patched-solaris-x86/jqr-00check.html

A few other platforms having warnings, which are all

checking whether package ‘jqr’ can be installed ... WARNING
Found the following significant warnings:
  execute.c:55:21: warning: ISO C forbids zero-size array ‘entries’ [-Wpedantic]
  parser.y:178:72: warning: ISO C99 requires at least one argument for the "..." in a variadic macro
  jq/execute.c:55:21: warning: ISO C forbids zero-size array ‘entries’ [-Wpedantic]
See http://www.r-project.org/nosvn/R.check/r-release-linux-x86_64/jqr-00install.html for details.

Pretty printing stops working

I haven't identified why this happens, so a bit hard to reproduce. But it has happened a few times now, that pretty printing stops working, and "regular" printing becomes the default.

Anyone else experienced this?

Think it would be nice before CRAN to identify this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.