WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:json.JSONFromHDS
Description:
Id:json.JSONFromHDS
Category:accessor
Identifier Syntax

json.JSONFromHDS is an accessor using Active URI syntax with the following base identifiers:

Base
active:JSONFromHDS

and the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
operand
Mandatory
Representation (HDS)input HDS document
operator
Optional
Representation (java.lang.Object)(no description available)
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The following response representations can be returned for SOURCE requests:

SOURCE Representations
JSONObject

This accessor throws no documented exceptions.

Import Requirements

To use json.JSONFromHDS accessor you must import the module urn:org:netkernel:json:core:

<import>
  <uri>urn:org:netkernel:json:core</uri>
</import>

The JSONFromHDS accessor will convert the HDS structure into as direct a JSON representation as possible.

Normal operation is for nested nodes in the HDS tree to be converted into nested objects in the JSON representation. However a naming convention is implemented that allows for JSON arrays to be created instead, in this case the parent and child element node must share a comment root but the parent node's name must end with double underscore A (__A)

Only HDS node values of String, boolean, Number (base class of all primitive numbers) are supported. Other values are silently ignored.

Example

This HDS resource...

<root xmlns:hds="http://netkernel.org/hds">
  <a>1</a>
  <b hds:type="INTEGER">2</b>
  <part__A>
    <part>first part</part>
    <part>second part</part>
    <part>
      <a>1</a>
      <b hds:type="BOOLEAN">true</b>
    </part>
  </part__A>
</root>

will be converted to the following JSON

{"root":
	{
		"a": "1",
		"b": 2
		[	"first part",
			"second part",
			{	"a": "1",
				"b": true
			}
		]
	}
}

Operator

The optional operator argument supplies configuration to the conversion

<config>
  <removeRootElement>true</removeRootElement>
</config>

  • removeRootElement - removes the root element from the generated JSON.