Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slashes problem in Windows #46

Open
springimport opened this issue Dec 6, 2016 · 0 comments
Open

Slashes problem in Windows #46

springimport opened this issue Dec 6, 2016 · 0 comments

Comments

@springimport
Copy link

Currently I use the windows 10 x64 OpenServer and I have a problem with slashes in JSON.parse().

VM444:1 Uncaught SyntaxError: Unexpected token D in JSON at position 10
    at JSON.parse (<anonymous>)
    at (index):477

Page source:

root = JSON.parse('{"name":"\\D:\\OpenServer\\domains\\opcache-status","children":[{"name":"vendor","children":[{"name":"rlerdorf","children":[{"name":"opcache-status","children":[{"name":"opcache.php","size":54152}]}]}]},{"name":"index.php","size":712}]}');

My solution:

root = JSON.parse('<?php echo json_encode(str_replace('\\', '/', $dataModel->getD3Scripts())); ?>');

Result:

root = JSON.parse('{"name":"\/D:\/OpenServer\/domains\/opcache-status","children":[{"name":"vendor","children":[{"name":"rlerdorf","children":[{"name":"opcache-status","children":[{"name":"opcache.php","size":54464}]}]}]},{"name":"index.php","size":712}]}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant