Learn R Programming

jsontools (version 0.1.0)

json_path_exists: Does the path exist?

Description

Does the path exist?

Usage

json_path_exists(x, path)

Arguments

x

A JSON vector.

path

Path to element. This must be a valid JSONpath expression. For example "$.a.b[0] extracts the 1 in {"a": {"b": [1, 2]}}.

Value

A logical vector.

Examples

Run this code
# NOT RUN {
json_path_exists(
  c(
    '{"a": 1}',
    '{"b": 2}',
    "[1, 2]",
    NA_character_
  ),
  "$.a"
)
# }

Run the code above in your browser using DataLab