Macaulay2 » Documentation
Packages » MRDI » Namespace » addNamespace
next | previous | forward | backward | up | index | toc

addNamespace -- register a namespace for MRDI serialization

Description

This method registers a new namespace for use with saveMRDI and loadMRDI. A namespace must be registered before any save or load methods can be added to it using addSaveMethod or addLoadMethod.

The namespace, URL, and version are written into the _ns field of the MRDI JSON output.

The "Macaulay2" and "Oscar" namespaces are registered automatically when the package is loaded.

i1 : addNamespace("MySystem", "https://example.com", "1.0")
i2 : addLoadMethod("MyInt",
         (params, data) -> value data,
         Namespace => "MySystem")

o2 = FunctionClosure[currentString:3:4-3:32]

o2 : FunctionClosure
i3 : loadMRDI "{\"_ns\":{\"MySystem\":[\"https://example.com\",\"1.0\"]},\"_type\":\"MyInt\",\"data\":\"42\"}"

o3 = 42

Ways to use addNamespace:

  • addNamespace(String,String,String)

For the programmer

The object addNamespace is a method function.


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/MRDI.m2:826:0.