Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An thin wrapper for the AJV Json Validator for R

NotificationsYou must be signed in to change notification settings

jdthorpe/ajvr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Theajv library is a very thin wrapper around the awesomeAJV JSON validation library. Theessential change between the syntax presented in the officialAJVReadme is exchanging JavaScript's dotoperator (.) with R's dollar-sign operator ($).

Note that care must be taken in transforming R objects to JSON, because ofR's everything-is-a-vector philosopy. Hence, for convenience file paths tovalid JSON (.json) and YAML (.yml or.yaml) may be used wherever anobject is expected.

Installation

# install.packages("devtools") # (if not already installed)devtools::install_github("jdthorpe/ajvr")

Getting started

The fastest validation call:

library('ajv')ajv= Ajv()# options can be passed, e.g. list(allErrors= TRUE)validate=ajv$compile(schema)valid= validate(data)if (!valid) print(validate$errors)

or with less code

# ...valid=ajv$validate(schema,data)if (!valid) print(ajv$errors)# ...

or

# ...ajv$addSchema(schema,'mySchema')valid=ajv$validate('mySchema',data)if (!valid) print(ajv$errorsText())# ...

Note that in each of these calls,schema anddata arguments may be avalid JSON string, an R object (i.e.list(...)), a connection to a JSONfile, or the file name of JSON or YAML file. YAML files are parsed viajs-yaml'ssafeLoad() method.

SeeAPI andOptions for more details.

About

An thin wrapper for the AJV Json Validator for R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp