back MT-JSON Conversion

Back and forth conversion between MT messages and JSON

The JSON format version contains structures for each message block and its inner fields. For the headers the information is split in a comprehensive list of fields, while for the text block the structure will contain the plain name/value tuples.

The conversion is done directly from the AbstractMT (actually its subclasses, for example MT103) object calling the json() method. And the same can be done with SwiftMessage#toJson() in the backbone model.

The result will be a String with JSON content similar to the following example:

	{ "version" : 1, "timestamp" : '2017-06-05 04:32 -0300', "data" : { 
		"block1" : { 
			"applicationId" : "F", 
			"serviceId" : "01", 
			"logicalTerminal" : "BICFOOYYAXXX", 
			"sessionNumber" : "8683", 
			"sequenceNumber" : "497519" 
		} ,
  		"block2" :  { 
			"messageType" : "103", 
			"senderInputTime" : "1535", 
			"MIRDate" : "051028", 
			"MIRLogicalTerminal" : "ESPBESMMAXXX", 
			"MIRSessionNumber" : "5423", 
			"MIRSequenceNumber" : "752247", 
			"receiverOutputDate" : "051028", 
			"receiverOutputTime" : "1535", 
			"messagePriority" : "N" 
		} ,  
		"block4" : [ 
			{ "20" : "0061350113089908" }, 
			{ "13C" : "/RNCTIME/1534+0000" },
			(...)
			{ "72" : "/BNF/TRANSF. BCO. FOO" }  ]
		}
	}
top

Related API documentation can be found online at AbstractMT and SwiftMessage

The full code sample can be found at Github