Skip to contents

The value's document: "$type", "$types" (the version of every type it contains), "$declarations" (the hash of what the declaration of each says about a value), then its fields in declaration order.

Usage

r8to_json(x, declarations = FALSE)

Arguments

x

An R8 value.

declarations

Logical: Write the declarations of the types too, as IR documents in "$ir", so that r8from_json() can tell what differs after a declaration changes, and read the document where its fields mean the same.

Value

Character: The JSON document.

Examples

op <- options(r8.namespace = "demo")
Point <- new_struct("Point", fields = list(x = type_double(), y = type_double()))
r8to_json(Point(x = 1, y = 2))
#> [1] "{\"$type\":\"demo::Point\",\"$types\":{\"demo::Point\":1},\"$declarations\":{\"demo::Point\":\"sha256:8ce843e62f596c9523b6043518c527fd2c93cb229aedecee4a90d9e041349b7a\"},\"x\":1,\"y\":2}"
options(op)