Parse is returning Arrays with a single object inside instead of the object directly
the-darc opened this issue · comments
In previous versions of the banking.js, the JSON in the body
property of the returned object of methods Banking.parseFile
and Banking.parse
respected the interface documented in the Readme.md#Response.
Since the version 1.0.0 it uses arrays with a single object inside instead of the object directly.
Example:
Response body
for sample.ofx in v0.3.3 and previous versions:
{
"OFX": {
"SIGNONMSGSRSV1": {
"SONRS": {
"STATUS": {
"CODE": "0",
"SEVERITY": "INFO",
"MESSAGE": "SUCCESS"
},
"DTSERVER": "20120126212302.454[-8:PST]",
"LANGUAGE": "ENG",
"FI": {
"ORG": "DI",
"FID": "321081669"
}
}
},
(... and more ...)
}
Response body
for sample.ofx in v1.0.0:
{
"OFX":{
"SIGNONMSGSRSV1":[
{
"SONRS":[
{
"STATUS":[
{
"CODE":[
"0"
],
"SEVERITY":[
"INFO"
]
}
],
"DTSERVER":[
"20120127235919.500"
],
"LANGUAGE":[
"ENG"
],
"DTPROFUP":[
"20050531070000.000"
],
"FI":[
{
"ORG":[
"WFB"
],
"FID":[
"3000"
]
}
],
(... and more ...)
}
Modify the top of ofx.js to look like this and it works. I don't know why xml2js decided arrays should be default...
var xml2js = require('xml2js')
, parseString = new xml2js.Parser({explicitArray: false}).parseString