Skip to content

rgusmero/edi2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edi2json

Convert EDIFACT to "raw" JSON

A tiny utility to convert EDIFACT to "raw" JSON. With "raw" we mean that the final JSON is composed of "arrays of arrays of (arrays of) strings". Higher level EDIFACT must be managed afterwards.

Requirements:

License: 3-caluse BSD

Author: Riccardo Gusmeroli - [email protected]

Want windows executale? See "RELEASES" above

Example usage:

edi2json edi.txt json.txt

with edi.txt (from Wikipedia):

UNA:+.? '
UNB+UNOB:2+8022628000004:14+4306517008994:14+050805:0941+8++DESADV+++EANCOM'
UNH+1+DESADV:D:96A:UN:EAN005'
BGM+351::9+007774+9'
DTM+137:20050714:102'
DTM+11:20050805:102'
DTM+2:20050714:102'
RFF+DQ:007774'
RFF+ON:509671432'
NAD+SU+8022628000004::9'
NAD+BY+4306517005092::9'
NAD+DP+4306517005078::9'
CPS+1'
LIN+1++8022628900014:EN'
PIA+1+90001:SA+5082951:BY'
IMD+F++:::COMP.SAFARI 65 C/SPECCH.MOLA'
QTY+12:66.00:PCE'
QTY+21:66.00:PCE'
CNT+2:1'
UNT+18+1'
UNZ+1+8'

produces json.txt:

[
	[
		[
			"\nUNB"
		],
		[
			"UNOB",
			"2"
		],
		[
			"8022628000004",
			"14"
		],
		[
			"4306517008994",
			"14"
		],
		[
			"050805",
			"0941"
		],
		[
			"8"
		],
		[
			""
		],
		[
			"DESADV"
		],
		[
			""
		],
		[
			""
		],
		[
			"EANCOM"
		]
	],
	[
		[
			"\nUNH"
		],
		[
			"1"
		],
		[
			"DESADV",
			"D",
			"96A",
			"UN",
			"EAN005"
		]
	],
	....

(please note the "\n" before "UNB")