Title: | Typed JSON |
---|---|
Description: | TSON, short for Typed JSON, is a binary-encoded serialization of JSON like document that support JavaScript typed data (https://github.com/tercen/TSON). |
Authors: | Alexandre Maurel |
Maintainer: | Alexandre Maurel <[email protected]> |
License: | Apache License Version 2.0 |
Version: | 1.6.1 |
Built: | 2024-11-01 06:10:28 UTC |
Source: | https://github.com/tercen/tson |
This function convert a raw vector into a list following TSON specification binary-encoded format.
fromTSON(bytes)
fromTSON(bytes)
bytes |
A raw vector |
A list
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) bytes = toTSON(list) object = fromTSON(bytes)
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) bytes = toTSON(list) object = fromTSON(bytes)
Read TSON specification binary-encoded format from a connection.
readTSON(con)
readTSON(con)
con |
A connection or a raw vector |
A list
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) con = rawConnection(raw(0), "r+") writeTSON(list, con) bytes = rawConnectionValue(con) close(con) con = rawConnection(bytes, "r") object = readTSON(con)
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) con = rawConnection(raw(0), "r+") writeTSON(list, con) bytes = rawConnectionValue(con) close(con) con = rawConnection(bytes, "r") object = readTSON(con)
This function convert a list into raw following TSON specification binary-encoded format.
toTSON(object)
toTSON(object)
object |
A list |
A raw vector
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) bytes = toTSON(list)
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) bytes = toTSON(list)
Make a tson character
tson.character(object)
tson.character(object)
object |
A vector or list |
A tson character
Make a tson double
tson.double(object)
tson.double(object)
object |
A vector or list |
A tson double
Make a tson float32 vector
tson.float32.vec(object)
tson.float32.vec(object)
object |
A vector or list |
A tson float32 vector
Make a tson integer
tson.int(object)
tson.int(object)
object |
A vector or list |
A tson integer
Make a tson int16 vector
tson.int16.vec(object)
tson.int16.vec(object)
object |
A vector or list |
A tson int16 vector
Make a tson int16 vector
tson.int64.vec(object)
tson.int64.vec(object)
object |
A vector or list |
A tson int64 vector
Make a tson int8 vector
tson.int8.vec(object)
tson.int8.vec(object)
object |
A vector or list |
A tson int8 vector
Required to generate empty map.
tson.map(object)
tson.map(object)
object |
A vector or list |
A tson map
Make a tson scalar (ie: singleton)
tson.scalar(obj)
tson.scalar(obj)
object |
A vector or list |
A tson scalar
Make a tson uint16 vector
tson.uint16.vec(object)
tson.uint16.vec(object)
object |
A vector or list |
A tson uint16 vector
Make a tson uint32 vector
tson.uint32.vec(object)
tson.uint32.vec(object)
object |
A vector or list |
A tson uint32 vector
Make a tson uint64 vector
tson.uint64.vec(object)
tson.uint64.vec(object)
object |
A vector or list |
A tson uint64 vector
Make a tson uint8 vector
tson.uint8.vec(object)
tson.uint8.vec(object)
object |
A vector or list |
A tson uint8 vector
Write TSON specification binary-encoded format to a connection.
writeTSON(object, con)
writeTSON(object, con)
object |
A list |
con |
A connection |
invisibly NULL
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) con = rawConnection(raw(0), "r+") writeTSON(list, con) bytes = rawConnectionValue(con) close(con) con = rawConnection(bytes, "r") object = readTSON(con)
## Example library(rtson) list = list(integer=42L, double=42, bool=TRUE, uint8=tson.uint8.vec(c(42,0)), uint16=tson.uint16.vec(c(42,0)), uint32=tson.uint32.vec(c(42,0)), int8=tson.int8.vec(c(42,0)), int16=tson.int16.vec(c(42,0)), int32=as.integer(c(42,0)), float32=tson.float32.vec(c(0.0, 42.0)), float64=c(42.0,42.0), map=list(x=42, y=42, label="42"), list=list("42",42) ) con = rawConnection(raw(0), "r+") writeTSON(list, con) bytes = rawConnectionValue(con) close(con) con = rawConnection(bytes, "r") object = readTSON(con)