I’m using Filesaver.js to save annotations by annotorious.
My code is as follows:
<code> const save = () => {
let js = JSON.stringify(anno.getAnnotations());
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
</code>
<code> const save = () => {
let js = JSON.stringify(anno.getAnnotations());
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
</code>
const save = () => {
let js = JSON.stringify(anno.getAnnotations());
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
The JSON file starts with:
<code> [{"type":"Annotation","body":[{ .....
</code>
<code> [{"type":"Annotation","body":[{ .....
</code>
[{"type":"Annotation","body":[{ .....
But for various reasons I would need the text to start like this:
<code> var items = [{"type":"Annotation","body":[{ .....
</code>
<code> var items = [{"type":"Annotation","body":[{ .....
</code>
var items = [{"type":"Annotation","body":[{ .....
Is there any way to add “var items = ” to the blob / string that i s being saved? Some sort of concatenate function?
I’m figuring something like this:
<code> const save = () => {
let js = JSON.stringify("var items = "+(anno.getAnnotations()));
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
</code>
<code> const save = () => {
let js = JSON.stringify("var items = "+(anno.getAnnotations()));
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
</code>
const save = () => {
let js = JSON.stringify("var items = "+(anno.getAnnotations()));
let blob = new Blob([js], {type: 'application/js'});
saveAs(blob, 'annotations.json');
}
Thanks a lot!