# Save scene to database

**URL:** <https://discourse.threejs.org/t/save-scene-to-database/18499>\
**Category:** Questions\
**Tags:** scene\
**Created:** [September 7, 2020, 2:24pm UTC](https://discourse.threejs.org/t/save-scene-to-database/18499 "2020-09-07T14:24:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirko.simanic](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mirko.simanic](https://discourse.threejs.org/u/mirko.simanic)\
**Post date:** [September 7, 2020, 2:24pm UTC](https://discourse.threejs.org/t/save-scene-to-database/18499/1 "2020-09-07T14:24:49Z")

</div>

Hello,

I am trying to save the scene into the database and read it from there.  
The first thing I did was to use scene.toJSON() function and I saved this value.

But when I try to load this scene from the database I get nothing. Is it possible to have oposite to toJSON function that I could use in this case?

I did the test with ObjectLoader in the following way:  
console.log(scene);  
sceneJSON = scene.toJSON(); // here I have the json file

```
    //here i am trying to get to the scene again:
    var loader = new THREE.ObjectLoader();

    loader.load(sceneJSON,
        function ( json ) {
          console.log(json);

    });

```

But what I am getting for the last console.log is:

```
    three.js:40357 Uncaught TypeError: url.lastIndexOf is not a function
    at Object.extractUrlBase (three.js:40357)
    at ObjectLoader.load (three.js:40645)
    at saveSceneAs (index.js:710)
    at HTMLAnchorElement.onclick (VM5016 index.php:71)

```

Many thanks in advance!

Mirko

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [September 7, 2020, 7:44pm UTC](https://discourse.threejs.org/t/save-scene-to-database/18499/2 "2020-09-07T19:44:20Z")

</div>

A complete round-trip usually looks like so:

```javascript
const serializedScene = JSON.stringify( scene.toJSON() );
const scene = new THREE.ObjectLoader().parse( JSON.parse( serializedScene ) );

```

So you don’t use `ObjectLoader.load()`.

---

<div class="post-metadata">

**Author:** ![mirko.simanic](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mirko.simanic](https://discourse.threejs.org/u/mirko.simanic)\
**Post date:** [September 7, 2020, 7:56pm UTC](https://discourse.threejs.org/t/save-scene-to-database/18499/3 "2020-09-07T19:56:15Z")

</div>

Yes! This is what i was looking for.

Thanks a lot mate!
