parseEvidence: Convert EvidenceSet objects to and from JSON

parseEvidenceR Documentation

Convert EvidenceSet objects to and from JSON

Description

The as.json function takes an EvidenceSet (among other objects) and turns it into JSON. The function parseEvidence takes the list produced as the output to fromJSON and turns it back into an EvidenceSet object.

Usage

parseEvidence(rec)
## S4 method for signature 'EvidenceSet,list'
as.jlist(obj, ml, serialize=TRUE)

Arguments

rec

A list which comes from running fromJSON on a JSON string, or database extraction method.

obj

The object being serialized; usually attributes(obj).

ml

A list of fields of the object.

serialize

A logical flag. If true, serializeJSON is used to protect the data field (and other objects which might contain complex R code.

Details

See the description for as.json for more description of the JSON conversion prototocl.

The parseEvidence method is designed to be used with the getOneRec and getManyRecs functions for fetching information from the database.

Value

The function parseEvidence returns an object of class EvidenceSet.

The as.jlist method returns a list which can be passed to toJSON to produce legible JSON from the R object.

Author(s)

Russell Almond

See Also

EvidenceSet, as.json, getOneRec, getManyRecs

Examples


e1 <- EvidenceSet(uid="S1",app="Test",context="PPcompEM",
                  obs=list("CompensatoryObs"="Right"))

e2 <- EvidenceSet(uid="S1",app="Test",context="PPdurAttEM",
                  obs=list("Attempts"=2,"Duration"=38.3))

e1.ser <- as.json(e1)
e1a <- parseEvidence(jsonlite::fromJSON(e1.ser))
e2.ser <- as.json(e2)
e2a <- parseEvidence(jsonlite::fromJSON(e2.ser))

stopifnot(all.equal(e1,e1a), all.equal(e2,e2a))


ralmond/EABN documentation built on Aug. 30, 2023, 12:52 p.m.