{"size": 1333, "ext": "scrbl", "max_stars_repo_path": "scribblings/eval.scrbl", "max_stars_repo_name": "pmatos/json-pointer", "max_stars_repo_stars_event_min_datetime": "2017-12-24T07:17:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-24T18:34:01.000Z", "max_issues_repo_path": "scribblings/eval.scrbl", "max_issues_repo_name": "pmatos/json-pointer", "max_issues_repo_issues_event_min_datetime": "2018-07-30T13:49:07.000Z", "max_issues_repo_issues_event_max_datetime": "2021-03-27T10:04:27.000Z", "max_forks_repo_path": "scribblings/eval.scrbl", "max_forks_repo_name": "pmatos/json-pointer", "max_forks_repo_forks_event_min_datetime": "2021-03-24T10:53:51.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-24T10:53:51.000Z"}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 53.32, "max_line_length": 281, "alphanum_fraction": 0.7494373593}
#lang scribble/manual

@require[@for-label[racket/base
	            json
		    json-pointer]]

@title{Evaluation of JSON Pointers}

@defproc[
(json-pointer-value
[jp (or/c json-pointer-expression? json-pointer?)]
[doc jsexpr?])
jsexpr?]

Given a JSON Pointer and a JSON document, evaluate the JSON Pointer within the document. The result is a @racket[jsexpr?], if all goes well.

(For the first argument both @racket[json-pointer?]—a string—as well as a @racket[json-pointer-expression?]—a list of strings—are allowed. When given a @racket[json-pointer?], it will be parsed into a @racket[json-pointer-expression?], with which the real computation takes place.)

If things @emph{don’t} go well, @racket[json-pointer-value] function throws an exception (of type @racket[exn:fail?]). These are the conditions under which evaluation might go awry:

@itemlist[
  @item{The document, or some salient part of it, is not the right kind of JSON value.  For traversal through a JSON document to make sense, we need to be dealing with JSON objects or arrays, not with strings, numbers, or null values.}
  @item{The JSON Pointer refers to a non-existent part of the document. This happens if one refers to a non-existent object property or negative, out-of-bounds or nonsensical array indices such as @racket["radical"] or @racket[3.1415]).}
]
