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.JSONToHDS
Description:
Id:json.JSONToHDS
Category:accessor
Identifier Syntax

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

Base
active:JSONToHDS

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

ArgumentRulesTypingDescription
operand
Mandatory
Representation (JSONObject, JSONArray)input JSON Object
operator
Optional
Representation (HDS)configuration
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The following response representations can be returned for SOURCE requests:

SOURCE Representations
HDSHDS2 Document

This accessor throws no documented exceptions.

Import Requirements

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

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

The JSONToHDS accessor will convert the JSON Object into as direct a HDS document as possible.

JSON Arrays are converted to HDS nodes with a double underscore A (__A) suffix.

Numbers and booleans are preserved.

Example

This JSON resource...

{"root":
	{	"a": "1",
		"b": 2,
		"c": [ "1",2, { a: "1" } ]
	}
}

will be converted to the following HDS form...

<root xmlns:hds="http://netkernel.org/hds">
  <a>1</a>
  <b hds:type="INTEGER">2</b>
  <c__A>
    <c>1</c>
    <c hds:type="INTEGER">2</c>
    <c>
      <a>1</a>
    </c>
  </c__A>
</root>

Operator

The optional operator argument supplies configuration to the conversion

<config>
  <addRootElement>MyRootElement</addRootElement>
  <convertToString>true</convertToString>
</config>

  • addRootElement - adds a root tag so that json without a root object will create well formed XML. The

name of the root element should be supplied as the text value of the configuration node

  • convertToString - if "true" then all booleans and numerics in the JSON are converted to string values

within the resulting HDS document