You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a layer to the library where a complex condition can be constructed by traversing a JSON element with a predefined structure. For example, in the following snippet, reading the top-level element would trigger the instantiation of a ForAll function, with the parameters provided in the contents field.
Since a function can itself use other functions, this traversal and the corresponding construction of objects must be recursive.
Structural modifications
Add a new class called Deserializer, which implements a method deserialize(j) that accepts a JSON structure j and produces a Function object.
Add to all descendants of Function a static method deserialize(d, j), where d is a deserializer and j is a JSON structure.
The task of Deserializer.deserialize(j) is to check the JSON structure, determine what function class C it corresponds to, and call C.deserialize(this, j) to obtain an instance of that class.
The task of C.deserialize(d, j) is to read the JSON structure and create an appropriate instance of the class by reading the fields. If one of these fields is itself a JSON structure j' defining a function, the class can call d.deserialize(j') to obtain that object recursively.
JSON structure
The JSON structure for each function is an object with two mandatory fields:
name: a string that contains the name of the class. Deserializer uses this field to dispatch the call to deserialize(this, j) to the proper static class method
contents: an object that contains any fields that class needs to instantiate an object; this is the part of the JSON that is sent to a class' deserialize static method. What these fields are is specific to each function. For example, Addition requires an arity to be instantiated, so one of the fields inside contents could be arity associated to a number.
The text was updated successfully, but these errors were encountered:
Add a layer to the library where a complex condition can be constructed by traversing a JSON element with a predefined structure. For example, in the following snippet, reading the top-level element would trigger the instantiation of a
ForAll
function, with the parameters provided in thecontents
field.Since a function can itself use other functions, this traversal and the corresponding construction of objects must be recursive.
Structural modifications
Deserializer
, which implements a methoddeserialize(j)
that accepts a JSON structurej
and produces aFunction
object.Function
a static methoddeserialize(d, j)
, whered
is a deserializer andj
is a JSON structure.The task of
Deserializer.deserialize(j)
is to check the JSON structure, determine what function classC
it corresponds to, and callC.deserialize(this, j)
to obtain an instance of that class.The task of
C.deserialize(d, j)
is to read the JSON structure and create an appropriate instance of the class by reading the fields. If one of these fields is itself a JSON structurej'
defining a function, the class can calld.deserialize(j')
to obtain that object recursively.JSON structure
The JSON structure for each function is an object with two mandatory fields:
name
: a string that contains the name of the class.Deserializer
uses this field to dispatch the call todeserialize(this, j)
to the proper static class methodcontents
: an object that contains any fields that class needs to instantiate an object; this is the part of the JSON that is sent to a class'deserialize
static method. What these fields are is specific to each function. For example,Addition
requires an arity to be instantiated, so one of the fields insidecontents
could bearity
associated to a number.The text was updated successfully, but these errors were encountered: