How to save and restore annotation state

I want to save and restore annotation state in cornerstone in a persistent way
Save state into something like a BD and restoring it again whenever I want
I’m currently trying the most primitive option, converting the result of cornerstoneTools.annotation.state.getAnnotationManager().saveAnnotations() into json and storing it, but it isn’t working when I try to restore it

Take a look at

We have a cornerstone examples to show you basics

https://www.cornerstonejs.org/live-examples/dynamicallyaddannotations

You can see how to do it in OHIF like this

My current problem is managing more complex anotation types like the ones with splines, the function “addAnotation” isn’t working with the spline data causing and error when trying to render the anotation