Class JsonTransformComponent
Implements a message pipeline component that transforms intercepted message from XML to JSON format and vise-versa.
Implements
Inherited Members
Namespace: Nevatech.Vsb.Repository.Processing
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class JsonTransformComponent : MessagePipelineComponentBase, IValidator, IEquatable<MessagePipelineComponentBase>, IExtensibleDataObject
Constructors
JsonTransformComponent()
Declaration
public JsonTransformComponent()
Fields
ElementName
Name of the root element when object is serialized to XML.
Declaration
public const string ElementName = "TRANSFORM-JSON"
Field Value
Type | Description |
---|---|
System.String |
Properties
AllowedPositions
Gets the message processing pipeline position(s) supported by the component: inbound request or inbound response.
Declaration
public override MessagePipelinePositions AllowedPositions { get; }
Property Value
Type | Description |
---|---|
MessagePipelinePositions |
Overrides
AppendRoot
Gets or sets the flag indicating that root element(s) must be added to deserialized XML. Setting this flag to True is highly recommended to increase conversion reliability and to extend variety of the supported JSON messages.
Declaration
public bool AppendRoot { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ConversionType
Gets or sets the message conversion type: XML to JSON, JSON to XML, or Auto.
Declaration
public MessageConversionType ConversionType { get; set; }
Property Value
Type | Description |
---|---|
MessageConversionType |
CreateJsonArrays
Gets or sets the flag indicating that all but empty XML elements must be converted to arrays during XML-to-JSON transformation. This allows for a consistent (insensitive to the number of elements) JSON representation of XML collections.
Declaration
public bool CreateJsonArrays { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
JsonpFunctionName
Gets or sets the default name of the JSONP function to be used if query parameter defined in JsonpParameterName property is not passed. If JsonpParameterName property is not set then value assigned to this property is used to name JSONP function. Setting both JsonpFunctionName and JsonpParameterName to Null disables JSONP transformation.
Declaration
public string JsonpFunctionName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
JsonpParameterName
Gets or sets the query parameter name to be used for retrieving JSONP function name. If parameter is not passed and JsonpFunctionName is not set then JSONP transformation is not performed. Setting both JsonpFunctionName and JsonpParameterName to Null disables JSONP transformation.
Declaration
public string JsonpParameterName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
OmitJsonRootObject
Gets or sets the flag indicating the JSON root object shall not be written when deserialized from XML. If set to True the XML root element will be omitted, so the XML like "<root><fieldA>1</fieldA><fieldB>2</fieldB></root>" will be converted to JSON like "{'fieldA':'1', 'fieldB':'2'}" instead of "{'root': {'fieldA':'1', 'fieldB':'2'}}".
Declaration
public bool OmitJsonRootObject { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
PreserveXmlNamespaces
Gets or sets the flag indicating that XML namespace declarations and prefixes must be kept in JSON during XML-to-JSON transformation, so that resulting JSON could be converted back to the original XML. By default (or if it is set to False) all namespaces will be removed to do not clutter JSON string.
Declaration
public bool PreserveXmlNamespaces { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Equals(MessagePipelineComponentBase)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(MessagePipelineComponentBase other)
Parameters
Type | Name | Description |
---|---|---|
MessagePipelineComponentBase | other | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified object is equal to the current object; otherwise, false. |
Overrides
Equals(Object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Returns hash code for the value of this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Hash code for the value of this instance. |
Overrides
ProcessMessage(MessagePipelineContext)
Inspects the message and transforms its content from XML to JSON or vice-versa.
Declaration
public override MessagePipelineResult ProcessMessage(MessagePipelineContext context)
Parameters
Type | Name | Description |
---|---|---|
MessagePipelineContext | context | Provides the message processing context. |
Returns
Type | Description |
---|---|
MessagePipelineResult | Value indicating if message should continue on its way to the recipient or must be stopped and returned to the sender. |
Overrides
ToString()
Returns string representation of the object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representing the object's content. |
Overrides
Validate()
Evaluates the state of the object.
Declaration
public override bool Validate()
Returns
Type | Description |
---|---|
System.Boolean | True if state is valid; otherwise, false. |