Skip to content

Commit

Permalink
After reading typeorm#5125, it seems the consensus was to return an e…
Browse files Browse the repository at this point in the history
…mpty object after a JSON parse failure
  • Loading branch information
mkornatz authored and imnotjames committed Oct 9, 2020
1 parent a087871 commit 6f8146e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/util/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class DateUtils {
try {
return JSON.parse(value);
} catch (err) {
return null;
return {};
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/github-issues/4440/issue-4440.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("github issues > #4440 simple-json column type throws error for string
await repo.save(post);
const postFound = await repo.findOne(1);
postFound!.id.should.eql(1);
postFound!.jsonField.should.eql("");
postFound!.jsonField.should.eql({});
})));

it("should correctly add retrieve simple-json field with some value", () =>
Expand Down

0 comments on commit 6f8146e

Please sign in to comment.