Mapfiles can be represented very effectively as JSON structures: most mapfile directives would map over to object properties. Those directives that would not do so are ones like LAYER and CLASS which would instead map over to arrays of objects, following the underlying mapserver C data structure.
Defining such a JSON structure would be very useful in the context of declarative mapping as it allows easy manipulation of the mapfile parameters from plain javascript code: the mapfile object representation could be created and modified at will and then used to instantiate a Map object using an asynchronous FromJSON() class method.
Although strictly speaking the argument to FromJSON() would be a native javascript object literal the name underlies the intent.
Implementation would involve a synchronous serialising object/function that returns a mapfile string: this string would then be used to instantiate the object.
Mapfiles can be represented very effectively as JSON structures: most mapfile directives would map over to object properties. Those directives that would not do so are ones like
LAYER
andCLASS
which would instead map over to arrays of objects, following the underlying mapserver C data structure.Defining such a JSON structure would be very useful in the context of declarative mapping as it allows easy manipulation of the mapfile parameters from plain javascript code: the mapfile object representation could be created and modified at will and then used to instantiate a
Map
object using an asynchronousFromJSON()
class method.Although strictly speaking the argument to
FromJSON()
would be a native javascript object literal the name underlies the intent.Implementation would involve a synchronous serialising object/function that returns a mapfile string: this string would then be used to instantiate the object.