Hi all, I recently needed to deal with json on the C++ side of things, and found the nlohmann json library. I made a small wrapper package: https://github.com/nfultz/RcppJson I was pleasantly surprised how easy it was to make a header-only package (by cannabalizing BH and copying the hpp file to inst/include). Maybe someone else will find this useful some day. Best, Neal Fultz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20181011/318eeb7b/attachment.html>
[Rcpp-devel] Manipulating json with Rcpp
4 messages · Neal Fultz, Dirk Eddelbuettel
On 11 October 2018 at 11:50, Neal Fultz wrote:
| I recently needed to deal with json on the C++ side of things, and found | the nlohmann json library. | | I made a small wrapper package: https://github.com/nfultz/RcppJson Cool. | I was pleasantly surprised how easy it was to make a header-only package | (by cannabalizing BH and copying the hpp file to inst/include). Why? Is LinkingTo: BH not good enough? | | Maybe someone else will find this useful some day. There are also R (at least) cpp-using package ndjson and validatejsonr on CRAN. Dirk
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
(Resending to list, sorry) | I was pleasantly surprised how easy it was to make a header-only package
| (by cannabalizing BH and copying the hpp file to inst/include). Why? Is LinkingTo: BH not good enough?
I'm not using Boost for json, instead using this https://nlohmann.github.io/json/ for the syntax sugar. But I wanted to start with something that was working instead of starting from scratch, in case there were package configuration that had to be set to make // [[Rcpp::depends(RcppJson)]] compile correctly. But Rcpp::depends seems to find everything automatically, it "just works".
| Maybe someone else will find this useful some day. There are also R (at least) cpp-using package ndjson and validatejsonr on CRAN.
Those are good finds. Not sure if you can use them from inside C++ though. It looks like Bob Rudis is also using the nlohmann/json.h, maybe I can ask him to move json.h from src/ to inst/include for his next release. I think that's all that needed to make Rcpp::depends / LinkingTo work.
On Thu, Oct 11, 2018 at 12:18 PM Dirk Eddelbuettel <edd at debian.org> wrote:
On 11 October 2018 at 11:50, Neal Fultz wrote: | I recently needed to deal with json on the C++ side of things, and found | the nlohmann json library. | | I made a small wrapper package: https://github.com/nfultz/RcppJson Cool. | I was pleasantly surprised how easy it was to make a header-only package | (by cannabalizing BH and copying the hpp file to inst/include). Why? Is LinkingTo: BH not good enough? | | Maybe someone else will find this useful some day. There are also R (at least) cpp-using package ndjson and validatejsonr on CRAN. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20181011/8161a1fd/attachment.html>
On 11 October 2018 at 13:43, Neal Fultz wrote:
| (Resending to list, sorry) | | | I was pleasantly surprised how easy it was to make a header-only package | > | (by cannabalizing BH and copying the hpp file to inst/include). | > | > Why? Is LinkingTo: BH not good enough? | > | | I'm not using Boost for json, instead using this | https://nlohmann.github.io/json/ for the | syntax sugar. Ok, clearer now what you meant. And yes -- a good header-only JSON solution. | But I wanted to start with something that was working instead of starting | from scratch, in case | there were package configuration that had to be set to make // | [[Rcpp::depends(RcppJson)]] | compile correctly. But Rcpp::depends seems to find everything | automatically, it "just works". Are you mostly using sourceCpp() ? Else use the package you created, and have other package use LinkingTo: to it. | > | Maybe someone else will find this useful some day. | > | > There are also R (at least) cpp-using package ndjson and validatejsonr on | > CRAN. Fair points. I was extrapolating because the last one I heard about what the JSON modifier (not on CRAN yet) which works at the C++ level: https://github.com/SymbolixAU/jsonify | Those are good finds. Not sure if you can use them from inside C++ though. | | It looks like Bob Rudis is also using the nlohmann/json.h, maybe I can ask | him to | move json.h from src/ to inst/include for his next release. I think that's | all that needed | to make Rcpp::depends / LinkingTo work. Yep! Dirk
| On Thu, Oct 11, 2018 at 12:18 PM Dirk Eddelbuettel <edd at debian.org> wrote:
| | >
| > On 11 October 2018 at 11:50, Neal Fultz wrote:
| > | I recently needed to deal with json on the C++ side of things, and found | > | the nlohmann json library. | > | | > | I made a small wrapper package: https://github.com/nfultz/RcppJson | > | > Cool. | > | > | I was pleasantly surprised how easy it was to make a header-only package | > | (by cannabalizing BH and copying the hpp file to inst/include). | > | > Why? Is LinkingTo: BH not good enough? | > | | > | Maybe someone else will find this useful some day. | > | > There are also R (at least) cpp-using package ndjson and validatejsonr on | > CRAN. | > | > Dirk | > | > -- | > http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org | > | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org