wdf-to-json
v0.0.3
Published
JangoMail Web DB Format to JSON
Downloads
3
Readme
jm-wdf-to-json
This package contains the code necessary to convert the JangoMail Web DB Format to JSON.
Contributing
Review the Contributing Guidelines before making changes
Install
Latest version
npm install https://bitbucket.org/jangocode/jm-wdf-to-json.git
Specific version
npm install https://bitbucket.org/jangocode/jm-wdf-to-json.git\#0.0.1
(where 0.0.1 is the tagged version)
Example
const wdfToJson = require('jm-wdf-to-json');
let data = 'EmailAddress,FirstName,LastName___ASDF---BREAKjohn@example.comWG0COLWG0JohnWG0COLWG0DoeWG0ROWWG0WANGO-ENDOFDATASTREAM';
try {
let json = wdfToJson.parse(data);
console.log(JSON.stringify(json));
} catch (err) {
console.error(err);
}
Terms
WDF
Web DB Format
Background
When making a connection to a web database, JangoMail uses a custom format to define the header, rows, columns, and data end.
Header
The header is comprised of a comma separated list of strings, with ___ASDF---BREAK
appended to the end.
Data
The data is column delimited by WG0COLWG0
and row delimited by WG0ROWWG0
.
File End
The end of the file is marked by a final WANGO-ENDOFDATASTREAM
.
Example
Using this example:
| EmailAddress | FirstName | LastName | | --- | --- | --- | | [email protected] | John | Doe | | [email protected] | Jane | Doe | | [email protected] | Alice | Smith |
This is how this would represented in WDF
(without newline breaks as shown in this example):
EmailAddress,FirstName,LastName___ASDF---BREAK
[email protected]
[email protected]
[email protected]
WANGO-ENDOFDATASTREAM
And this is what this module will convert it to:
[
{
"EmailAddress": "[email protected]",
"FirstName": "John",
"LastName": "Doe"
},
{
"EmailAddress": "[email protected]",
"FirstName": "Jane",
"LastName": "Doe"
},
{
"EmailAddress": "[email protected]",
"FirstName": "Alice",
"LastName": "Smith"
}
]