// Explicit cast operator is provided from treedata to JSON.
// Gets the name of an element.
// Gets the kind of an element.
// Gets the value of an element.
// Gets the count of children.
get Children(this json j) with DeclarationInfo {
Handcoded = true };
// Returns a single child matched the given name from all child elements.
optional json GetChild(this json j, TreedataName name) with DeclarationInfo { Handcoded = true };
// Returns a single element matched the given name from all descendant
// elements.
optional json GetDescendant(this json j, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a filtered array of treedata matched the given name from all
// children elements, in document order.
array GetChildren(this json j, TreedataName name) with
DeclarationInfo {Handcoded = true };
// Returns a filtered array of treedata matched the given name from all
// descendant elements, in document order.
array GetDescendants(this json j, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a treedata using the specified XPath-like expression with
// the specified mapping to resolve namespace prefixes.
// Returns an arbitrary one if more than one matches the path.
optional json Get(this json j, string @xpath, map resolver)
with DeclarationInfo { Handcoded = true };
// Returns an array of treedata using the specified XPath-like expression
// with the specified mapping to resolve namespace prefixes.
array GetMany(this json j, string @xpath, map resolver) with DeclarationInfo { Handcoded = true };
// Parses string containing JSON and builds JSON object from it
// Returns null if the data is not valid JSON format. json BuildJson(string data) with DeclarationInfo { Handcoded = true };
Treedata
The following DeclarationInfo aspect is for internal purposes only, and it is not supposed to be used by the end user.
// Represents a name for tree-structured data, backward compatible
// with XmlName to make it uniform with treedata and JSON.
type TreedataName {
// Gets the local (unqualified) part of the name.
string LocalName;
}
// Gets the name of an element.
optional TreedataName get Name(this treedata x) with DeclarationInfo {
Handcoded = true };
// Just a renaming to avoid making explicit references to xml.
// The same type makes sense to JSON as well.
typedef TreedataKind = XmlKind;
// Gets the kind of an element.
TreedataKind get Kind(this treedata t) with DeclarationInfo {
Handcoded = true };
// Gets the value of an element.
optional string get Value(this treedata t) with DeclarationInfo {
Handcoded = true };
// Gets the count of children.
int get ChildCount(this treedata t) with DeclarationInfo {
Handcoded = true };
// Gets the children elements.
array get Children(this treedata t) with DeclarationInfo {
Handcoded = true };
// Returns a single child matched the given name from all child elements.
optional treedata GetChild(this treedata t, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a single element matched the given name from all descendant
// elements.
optional treedata GetDescendant(this treedata t, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a filtered array of treedata matched the given name from all
// children elements, in document order.
array GetChildren(this treedata t, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a filtered array of treedata matched the given name from all
// descendant elements, in document order.
array GetDescendants(this treedata t, TreedataName name) with
DeclarationInfo { Handcoded = true };
// Returns a treedata using the specified XPath-like expression with the
// specified mapping to resolve namespace prefixes.
// Returns an arbitrary one if more than one matches the path.
optional treedata Get(this treedata x, string @xpath, map
resolver) with DeclarationInfo { Handcoded = true };
// Returns an array of treedata using the specified XPath-like expression
// with the specified mapping to resolve namespace prefixes.
array GetMany(this treedata x, string @xpath, map
resolver) with DeclarationInfo { Handcoded = true };
Both DateTime and TimeSpan are extern types for OPN.
module Standard;
extern type DateTime;
extern type TimeSpan;
optional DateTime ToDateTime (this string s);
optional TimeSpan ToTimeSpan(this string s);