objectAsJSON: Convert an ejObject into JSON

Description Usage Arguments Examples

View source: R/JSONGenerator.R

Description

Convert an ejObject into JSON

Usage

1
objectAsJSON(object)

Arguments

object

The object to be converted to JSON

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
library(sp)
library(rgdal)

#create an attribute
attribute <- create_ejAttribute("A test attribute","number",5.2,"metres")

#generate a polygon
polyPoints <- matrix(c(526870,181390,526817,181447,526880,181467,
		526885,181447,526909,181425,526870,181390),ncol=2,byrow=TRUE)
demoPolygon <- SpatialPolygons(list(Polygons(list(Polygon(polyPoints)),"1")),
		proj4string=CRS("+init=epsg:27700"))

#create an event
event <- create_ejEvent(id=1, name="A test Event", date=Sys.time(),
		location=demoPolygon, attributes=list(attribute, attribute))

#create a record
record <- create_ejRecord(id=1, attributes=list(attribute,attribute),
		events=list(event,event))

#generate some metadata
metadata <- create_ejMetadata(list(attribute, attribute))

#create an EpiJSON object
object <- create_ejObject(metadata=metadata, records=list(record,record))

#print it as JSON
objectAsJSON(object)

repijson documentation built on May 29, 2017, 2:12 p.m.