Skip to content

Exception in JSON.stringify #8428

Closed
Closed
@sjpt

Description

@sjpt
Description of the problem

Sample code:
mmm = new THREE.Mesh(); JSON.stringify(mmm);
throws exception
[(http://jsfiddle.net/sjpt/akmcv7Lh/32/)]

My larger scale code is stringifying at a higher level, and tries to avoid any attempt to stringify the THREE components by
JSON.stringify(o, function(key, value) { if value instanceof THREE.Object3D return undefined; ... }

This worked in older versions of THREE. However, the THREE.Object3D.prototype.toJSON code now gets called BEFORE my escape function, and the exception means my entire JSON.stringify fails, even though it didn't want to go near stringifying the THREE objects.

For now I have a nasty workaround of
delete THREE.Object3D.prototype.toJSON;
before calling the stringify, but that is obviously not a good long term or general solution.

Three.js version
  • Dev
  • r75
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • Linux
  • Android
  • IOS
Hardware Requirements (graphics card, VR Device, ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions