sofie-core icon indicating copy to clipboard operation
sofie-core copied to clipboard

Fix: JSONBlob

Open nytamin opened this issue 3 years ago • 0 comments

  • What is the current behavior? (You can also link to an open issue here) Wherever we do JSON.stringify and then JSON.parse() we risk bugs, because JSON.parse accepts any.

  • What is the new behavior (if this is a feature change)? By using JSONBlob we ensure that typings are kept and it's not as risky to parse strings anymore.

Usage:

interface A {
  a: number
}
const aBlob: JSONBlob<A> = JSONBlobStringify({ a: 1 })
const a: A = JSONBlobParse(aBlob)

nytamin avatar Sep 01 '22 13:09 nytamin