...
JSONMapping Handler performs the following functions:
- Convert Converts any FIX message to JSON and stores it to XML message (MsgType = n) containing JSON objectConvert or any other message type of the user's choice.
- Converts any JSON message contained in XML message (MsgType = n) containing JSON object or any other message type back to FIX formatmessage.
Configuration parameters
The handler is configured as part of the business logic in BL_Config.xml, along with other FIXEdge handlers.
The table below represents the JSONMapping Handler config parametersproperties.
Property name | Description | Required | |||||
---|---|---|---|---|---|---|---|
Common BL handlers configurationparametersproperties | |||||||
Name | Reference name used in the Business Logic Actions. Example: JSONMapping | Y | |||||
Description | A description defined by a user. Example: JSONMapping Handler | Y | |||||
DllName | Path to a library, starting from RootDir. Example: ./libJSONMapping.so | Y | |||||
VerifyHandlersVersion | If set to "true" FIXEdge C++ prevents the use of an unexpected version of the module in order to avoid incompatible changes between two different FIXEdge C++ versions. The recommended value is "true". If the version of the handler is different from the FIXEdge C++ version, the module will not be loaded and the corresponding error will be logged. | N | |||||
Specific JSONMapping Handler configurationparametersproperties | |||||||
Direction | The direction of the conversion. Valid values: FIX-to-JSON | JSON-to-FIX | Y | |||||
FIXVersionMessageType | The FIX version MsgType of the encoded message container. Applicable only to FIX-to-JSON encoding. Valid values: any MsgType value The default value: n | ||||||
FieldTag | The tag to put JSON to or to get JSON from depending on conversion direction. Valid values: any tag number The default value: 213 | N | |||||
IncludeCustomTags | Determines whatever to include custom tags to resulting JSON (the tag is used as a field name) or to accept custom tags from incoming JSON. If provided for Valid values: true | false The default value: false | N | |||||
FIXVersion and ParserVersion properties define the dictionary to use. FIX-to-JSON conversion | , it specifies the version of the FIX message to use instead of the version of the source message.If the FIXVersion parameter is defined but the ParserVersion parameter is not defined then the parser of the JSON : If the FIXVersion and ParserVersion properties are not defined then the container message will have the same version as the source message has. JSON-to-FIX conversion: If the FIXVersion and ParserVersion properties are not defined then the source container message property values will be used. | ||||||
ParserVersion | ParserVersion | The name of the parser (with @) or parser template string. If the ParserVersion parameter is defined but the FIXVersion parameter is not defined then the default FIX version willThe value of the ParserVersion property is parser template string. FIX-to-JSON conversion: The ParserVersion property defines which parser (dictionaries set) to use. If the ParserVersion property is not defined then the source message parser will be used. JSON-to-FIX conversion: The ParserVersion property defines which parser (dictionaries set) to use. If the ParserVersion is not defined then the parser of the source container FIX message will be used.
| N |
| N | ||
MessageType | MsgType of the encoded message. Applicable only to FIXVersion | The value of the FIXVersion property is the 'id' attribute of the protocol loaded from xml dictionary file. FIX-to-JSON Valid values: any MsgType value The default value: n | |||||
FieldTag | Valid values: any tag number The default value: 213 | N | |||||
IncludeCustomTags | Valid values: true | false The default value: falseconversion: The FIXVersion property defines which particular protocol version from the set (defined by the ParserVersion property) to use. If the FIXVersion property is not defined then the default application-level protocol version of parser defined by the ParserVersion property will be used. JSON-to-FIX conversion: The FIXVersion property defines the particular protocol version to use if JSON message doesn't provide the version explicitly by means of 1128 and 1129 tags when applicable. If the FIXVersion property is not defined then the default application-level protocol version of the parser defined by the ParserVersion property will be used.
| N |
FIX-to-JSON
...
Conversion Example
In the example below JSONMapping Handler is configured to convert FIX message to JSON message and store in the 213 tag of XML message (MsgType = n) containing JSON object.
BL Rule
...
Code Block | ||||
---|---|---|---|---|
| ||||
<FIXEdge> <BusinessLayer> <!-- Rule for status messages --> <!-- Rule messages from Simple Client --> <Rule> <Source> <FixSession SenderCompID="TESTI" TargetCompID="TESTA"/> </Source> <Action> <DllHandlers> <Handler Name="JSONMapping" Description="JSONMapping Handler" DllName="./JSONMappingHandler-MD-x64.dll" VerifyHandlersVersion="true"/> </DllHandlers> <Rule Description="Mapping handler with only default properties"> <Source> <FixSession SenderCompID="Client1" TargetCompID="Client2"/> </Source> <Action> <HandlerAction Name="JSONMapping" Direction="FIX-to-JSON" FieldTag="22222"/> <Send> <Send> <FixSession SenderCompID="TESTAClient2" TargetCompID="TESTIClient1"/> </Send> </Action> </Rule> <DefaultRule> <Action> <DoNothing/> </Action> </DefaultRule> </BusinessLayer> </FIXEdge> |
Input Message Sample
Code Block |
---|
8=FIX.4.4|9=91|35=W|49=TESTI|56=TESTA|34=2|52=20030204-09:25:43|55=TESTA|268=2|269=4|270=11|10=064 |
Output message sample
...
</Rule> |
Input Message
Code Block |
---|
8=FIXT.1.1|9=195|35=i|1128=10|49=Client1|56=Client2|34=2|52=20230221-11:09:15.850|117=1116226|296=2|302=0001|304=2|295=2|299=11|132=10|299=12|133=11|302=0002|304=3|295=3|299=21|132=12|299=22|133=13|299=23|133=14|10=046 |
Output Message
Code Block |
---|
8=FIXT.1.1|9=638|35=n|49=Client2|56=Client1|34=2|52=20230306-12:37:06.130|1128=10|212=560|213={"Header":{"BeginString":"FIXT.1.1","BodyLength":"195","MsgType":"i","ApplVerID":"10","SenderCompID":"Client1","TargetCompID":"Client2","MsgSeqNum":"2","SendingTime":"20230221-11:09:15.850"},"Body":{"QuoteID":"1116226","NoQuoteSets":[{"QuoteSetID":"0001","TotNoQuoteEntries":"2","NoQuoteEntries":[{"QuoteEntryID":"11","BidPx":"10"},{"QuoteEntryID":"12","OfferPx":"11"}]},{"QuoteSetID":"0002","TotNoQuoteEntries":"3","NoQuoteEntries":[{"QuoteEntryID":"21","BidPx":"12"},{"QuoteEntryID":"22","OfferPx":"13"},{"QuoteEntryID":"23","OfferPx":"14"}]}]},"Trailer":{}}|10=061 |
JSON-to-FIX Conversion Example
In the example below JSONMapping Handler is configured to convert JSON message contained in the 213 tag of XML message (MsgType = n) to FIX message with the same version as the source FIX message had.
BL Rule
Code Block | ||||
---|---|---|---|---|
| ||||
<DllHandlers>
<Handler Name="JSONMapping"
Description="JSONMapping Handler"
DllName="./JSONMappingHandler-MD-x64.dll"
VerifyHandlersVersion="true"/>
</DllHandlers>
<Rule Description="Default properties">
<Source>
<FixSession SenderCompID="Client1" TargetCompID="Client2"/>
</Source>
<Action>
<HandlerAction Name="JSONMapping" Direction="JSON-to-FIX" FIXVersion=""/>
<Send>
<FixSession SenderCompID="Client2" TargetCompID="Client1"/>
</Send>
</Action>
</Rule> |
Input Message
Code Block |
---|
8=FIXT.1.1|9=638|35=n|1128=10|49=Client1|56=Client2|34=2|52=20230306-12:27:01.730|212=560|213={"Header":{"BeginString":"FIXT.1.1","BodyLength":"195","MsgType":"i","ApplVerID":"10","SenderCompID":"Client1","TargetCompID":"Client2","MsgSeqNum":"2","SendingTime":"20230221-11:09:15.850"},"Body":{"QuoteID":"1116226","NoQuoteSets":[{"QuoteSetID":"0001","TotNoQuoteEntries":"2","NoQuoteEntries":[{"QuoteEntryID":"11","BidPx":"10"},{"QuoteEntryID":"12","OfferPx":"11"}]},{"QuoteSetID":"0002","TotNoQuoteEntries":"3","NoQuoteEntries":[{"QuoteEntryID":"21","BidPx":"12"},{"QuoteEntryID":"22","OfferPx":"13"},{"QuoteEntryID":"23","OfferPx":"14"}]}]},"Trailer":{}}|10=061 |
Output Message
Code Block |
---|
8=FIXT.1.1|9=195|35=i|49=Client2|56=Client1|34=2|52=20230306-12:27:01.736|1128=10|117=1116226|296=2|302=0001|304=2|295=2|299=11|132=10|299=12|133=11|302=0002|304=3|295=3|299=21|132=12|299=22|133=13|299=23|133=14|10=049 |