Skip to content

console.log TypeError: Converting circular structure to JSON #955

@NickIliev

Description

@NickIliev

Using tns-android@next ("version": "3.4.1-2018-02-22-01") and trying to print NativeScript View arguments (or other circular JSON objects) via console.log fails with

JS: ERROR Couldn't convert object to a JSON string: Uncaught TypeError: Converting circular structure to JSON
JS: ERROR CONTEXT Couldn't convert object to a JSON string: Uncaught TypeError: Converting circular structure to JSON

For example:

onStackLoaded(args: EventData) {
    console.log("onStackLoaded");
    console.log(args.object); // TypeError: Converting circular structure to JSON
    console.log("" + args.object); // OK prints StackLayout(9)

    console.log(JSON.stringify(args)); // JS: ERROR Couldn't convert object to a JSON string: Uncaught TypeError: Converting circular structure to JSON
    console.log("" + JSON.stringify(args)); // JS: ERROR CONTEXT Couldn't convert object to a JSON string: Uncaught TypeError: Converting circular structure to JSON
}

Steps to reproduce:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions