Skip to content

Commit

Permalink
Merge pull request #220 from camunda/alpha
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
jwulf authored Jul 29, 2024
2 parents d2be6f2 + 7536c9d commit 7c0ed0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"modeler",
"operate",
"camunda8",
"optimize"
"optimize",
"lossless-parser"
],
"editor.formatOnSave": true,

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"access": "public"
},
"author": "[email protected]",
"license": "Apache 2.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/camunda/camunda-8-js-sdk.git"
Expand Down Expand Up @@ -159,4 +159,4 @@
"typed-duration": "^1.0.12",
"uuid": "^7.0.3"
}
}
}
14 changes: 14 additions & 0 deletions src/__tests__/lib/LosslessJsonParser.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,17 @@ test('LosslessStringify correctly handles nested Dtos', () => {
`{"total":3,"decisionsOutputs":[{"someInt32Field":123,"someInt64Field":123}]}`
)
})

test('LosslessJsonParser correctly handles null objects', () => {
const json = `{"abc": [null, null, null] }`

const parsedDto = losslessParse(json)
expect(parsedDto.abc).toMatchObject([null, null, null]) // 3 (string)
})

test('LosslessStringify correctly handles null objects', () => {
const json = { abc: [null, null, null] }

const stringifiedDto = losslessStringify(json)
expect(stringifiedDto).toBe(`{"abc":[null,null,null]}`) // 3 (string)
})
5 changes: 4 additions & 1 deletion src/lib/LosslessJsonParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ function parseArrayWithAnnotations<T>(
* Convert all `LosslessNumber` instances to a number or throw if any are unsafe
*/
function convertLosslessNumbersToNumberOrThrow<T>(obj: any): T {
debug(`Parsing LosslessNumbers to numbers for ${obj.constructor.name}`)
debug(`Parsing LosslessNumbers to numbers for ${obj?.constructor?.name}`)
if (!obj) {
return obj
}
let currentKey = ''
try {
Object.keys(obj).forEach((key) => {
Expand Down

0 comments on commit 7c0ed0c

Please sign in to comment.