yyjsonr

Fast JSON package for R

https://github.com/coolbutuseless/yyjsonr

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Fast JSON package for R

Basic Info
Statistics
  • Stars: 157
  • Watchers: 6
  • Forks: 11
  • Open Issues: 4
  • Releases: 0
Created almost 3 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
title: yyjsonr
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  fig.height = 3,
  out.width = "100%"
)

library(tidyr)
library(yyjsonr)

if (FALSE) {
  covr::report(covr::package_coverage(
    line_exclusions = list('src/yyjson.c', 'src/yyjson.h')
  ))
}

if (FALSE) {
  pkgdown::build_site(override = list(destination = "../coolbutuseless.github.io/package/yyjsonr"))
}

# Makevars options to do some deep testing for CRAN

# Type conversions are sane
# PKG_FLAG=-Wconversion

# Pointer overflow checks i.e. dodgy pointer arithmetic
# PKG_CFLAGS+=-fsanitize=pointer-overflow -fsanitize-trap=pointer-overflow
# Then run in the debugger:
# R -d lldb 
# run
# testthat::test_local()
```



# yyjsonr 


![](https://img.shields.io/badge/cool-useless-green.svg)
[![CRAN](https://www.r-pkg.org/badges/version/yyjsonr)](https://cran.r-project.org/package=yyjsonr)
[![R-CMD-check](https://github.com/coolbutuseless/yyjsonr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/coolbutuseless/yyjsonr/actions/workflows/R-CMD-check.yaml)


`{yyjsonr}` is a fast JSON parser/serializer, which converts R data to/from JSON.

In most cases it is around 2x to 10x faster than `{jsonlite}` at both reading and writing JSON.

It is a wrapper for the [`yyjson`](https://github.com/ibireme/yyjson) C library (v0.11.1 May 2025).
`yyjson` is MIT licensed - see `LICENSE-yyjson.txt` in this package for more details - 
`readLines(system.file('LICENSE-yyjson.txt', package = 'yyjsonr', mustWork = TRUE))`

### What's in the box

This package contains specialized functions for each type of operation (read/write/validate) and the 
storage location of the JSON (string/file/raw vector/connection).

#### Vanilla JSON

|          | string              | file                 | raw             | conn             | options              |
|----------|---------------------|----------------------|-----------------|------------------|----------------------|
| read     | read_json_str()     | read_json_file()     | read_json_raw() | read_json_conn() | opts_read_json()     |
| write    | write_json_str()    | write_json_file()    |write_json_raw() |                  | opts_write_json()    |
| validate | validate_json_str() | validate_json_file() |                 |                  |                      |


#### NDJSON

|          | string              | file                 | raw              | conn             | options              |
|----------|---------------------|----------------------|------------------|------------------|----------------------|
| read     | read_ndjson_str()   | read_ndjson_file()   |read_ndjson_raw() |                  | opts_read_json()     |
| write    | write_ndjson_str()  | write_ndjson_file()  |write_ndjson_raw()|                  | opts_write_json()    |


#### GeoJSON

|          | string              | file                 | raw                 | conn             | options              |
|----------|---------------------|----------------------|---------------------|------------------|----------------------|
| read     | read_geojson_str()  | read_geojson_file()  |                     |                  | opts_read_geojson()     |
| write    | write_geojson_str() | write_geojson_file() |                     |                  | opts_write_geojson()    |


### Speed 

In the following plots, bigger is better, with `yyjsonr` results in blue.


#### JSON



#### NDJSON



#### GeoJSON



Note: Benchmarks were run on Apple M2 Mac.  See files `man/benchmark/benchmark*.Rmd` for details.

## Installation

This package can be installed from CRAN

``` r
install.packages('yyjsonr')
```


You can install the latest development version from [GitHub](https://github.com/coolbutuseless/yyjsonr) with:

``` r
# install.package('remotes')
remotes::install_github('coolbutuseless/yyjsonr')
```

Pre-built source/binary versions can also be installed from [R-universe](https://r-universe.dev)

``` r
install.packages('yyjsonr', repos = c('https://coolbutuseless.r-universe.dev', 'https://cloud.r-project.org'))
```




Simple JSON example
==============================================================================

```{r}
library(yyjsonr)

str <- write_json_str(head(iris, 3), pretty = TRUE)
cat(str)

read_json_str(str)
```


Simple GeoJSON example
==============================================================================

When parsing GeoJSON, `{yyjsonr}` returns an `sf` object.

```{r}
read_geojson_str(geojsonsf::geo_melbourne) |> 
  head() |>
  sf:::print.sf()
```
    
    
## Limitations

* Some datatypes are not currently supported. Please file an issue on GitHub if
  these types are critical for you.  Providing test cases also appreciated!:
    * Complex numbers
    * POSIXlt
    * Matrices of POSIXct / Date


Owner

  • Name: mikefc
  • Login: coolbutuseless
  • Kind: user
  • Location: Australia

Cool, but useless.

GitHub Events

Total
  • Issues event: 36
  • Watch event: 33
  • Delete event: 2
  • Issue comment event: 54
  • Push event: 53
  • Pull request event: 4
  • Fork event: 1
  • Create event: 3
Last Year
  • Issues event: 36
  • Watch event: 33
  • Delete event: 2
  • Issue comment event: 54
  • Push event: 53
  • Pull request event: 4
  • Fork event: 1
  • Create event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 79
  • Total Committers: 4
  • Avg Commits per committer: 19.75
  • Development Distribution Score (DDS): 0.038
Past Year
  • Commits: 27
  • Committers: 2
  • Avg Commits per committer: 13.5
  • Development Distribution Score (DDS): 0.037
Top Committers
Name Email Commits
mike m****c@c****m 76
shikokuchuo 5****o 1
hrbrmstr b****b@r****s 1
Krzysztof Dyba 3****b 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 56
  • Total pull requests: 9
  • Average time to close issues: 6 months
  • Average time to close pull requests: 5 months
  • Total issue authors: 30
  • Total pull request authors: 6
  • Average comments per issue: 2.29
  • Average comments per pull request: 1.67
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 12
  • Pull requests: 2
  • Average time to close issues: 3 months
  • Average time to close pull requests: 6 months
  • Issue authors: 11
  • Pull request authors: 1
  • Average comments per issue: 1.58
  • Average comments per pull request: 1.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • coolbutuseless (17)
  • anthonynorth (3)
  • hrbrmstr (2)
  • jd4ds (2)
  • shikokuchuo (2)
  • mmuurr (2)
  • JosiahParry (2)
  • kadyb (2)
  • sebastian-c (1)
  • statquant (1)
  • apalacio9502 (1)
  • neovom (1)
  • ecqiu (1)
  • rdatasculptor (1)
  • francisbarton (1)
Pull Request Authors
  • shikokuchuo (3)
  • mmuurr (2)
  • yihui (2)
  • kadyb (2)
  • ecqiu (2)
  • hrbrmstr (1)
Top Labels
Issue Labels
enhancement (7) bug (2) NULL/empty handling (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 2,253 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: yyjsonr

Fast 'JSON', 'NDJSON' and 'GeoJSON' Parser and Generator

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 2,253 Last month
Rankings
Dependent packages count: 28.4%
Dependent repos count: 36.4%
Average: 49.9%
Downloads: 84.9%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • bit64 * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests
.devcontainer/Dockerfile docker
  • ghcr.io/rocker-org/devcontainer/tidyverse ${VARIANT} build