json-ascii
Advanced tools
Comparing version 3.3.4 to 3.3.5
@@ -94,2 +94,17 @@ 'use strict' | ||
}) | ||
it('an object encoded using object-property-base64-ecoder is untouched by this library', () => { | ||
const jsonObject = { | ||
str: 'Zm9v', | ||
array: 'WyJmb28iLCJiYXIiXQ==', | ||
bar: 'eyJiYXoiOiJiYXoifQ==', | ||
untouched: 123, | ||
base64EncoderConfig: { | ||
str: {} | ||
} | ||
} | ||
const backFromString = JSONAscii.parseWithDecode(JSON.stringify(jsonObject), true) | ||
assertObjectEqual(jsonObject, backFromString) | ||
}) | ||
}) |
@@ -91,2 +91,17 @@ 'use strict' | ||
}) | ||
it('when working with kinesis analytics this gets turned into a string parse it and use it in that case', () => { | ||
const objectToDecode = { | ||
canonicalMessageJson: 'eyJ0ZXh0IjoiTVx1MDAxYVxuJiN4NjIxMTsifQ==', | ||
base64EncoderConfig: '{"text":{},"messageJson":{"type":"object"},"canonicalMessageJson":{"type":"object"},' + | ||
'"metadata":{"type":"object"}}' | ||
} | ||
const decodedObject = objectPropertyEncoder.decode(objectToDecode) | ||
assertObjectEqual({ | ||
canonicalMessageJson: { | ||
'text': 'M\u001a\n我' | ||
} | ||
}, decodedObject) | ||
}) | ||
}) |
@@ -26,6 +26,10 @@ 'use strict' | ||
decode(object, encoderConfiguraiton) { | ||
const fieldListConfiguration = encoderConfiguraiton || object.base64EncoderConfig | ||
let fieldListConfiguration = encoderConfiguraiton || object.base64EncoderConfig | ||
if (!fieldListConfiguration) { | ||
return object | ||
} | ||
if (_.isString(fieldListConfiguration)) { | ||
fieldListConfiguration = JSON.parse(fieldListConfiguration) | ||
} | ||
const returnObject = _.clone(object) | ||
@@ -32,0 +36,0 @@ |
{ | ||
"name": "json-ascii", | ||
"version": "3.3.4", | ||
"version": "3.3.5", | ||
"description": "encodes and decodes utf8 four byte characters", | ||
@@ -5,0 +5,0 @@ "main": "json-ascii.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11529
289