readJSON: read a message in JSON format

readJSON-methodsR Documentation

read a message in JSON format

Description

Method to read a Message in JSON format

Methods

signature(descriptor = "Descriptor", input = "ANY")

Read the message from a connection (file, etc ...)

signature(descriptor = "Descriptor", input = "character")

Read the message directly from the character string

Examples

## Not run: 
# example file that contains a "tutorial.AddressBook" message
book <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )

# read the message
message <- read( tutorial.AddressBook, book )

# Output in text format to a temporary file
out.file <- tempfile()
writeLines( message$toJSON(), file(out.file))

# Verify that we can read back in the message from a text file.
message2 <- readJSON( tutorial.AddressBook, file(out.file, "rb"))

# Verify that we can read back in the message from an unopened file.
message3 <- readJSON( tutorial.AddressBook, file(out.file))

\dontshow{
stopifnot( identical( message, message2) )
}

## End(Not run)

eddelbuettel/rprotobuf documentation built on April 28, 2024, 6:23 p.m.