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

JSON.parse(patterns) done on an object and not on a string #7

Open
oddball opened this issue Nov 27, 2019 · 1 comment
Open

JSON.parse(patterns) done on an object and not on a string #7

oddball opened this issue Nov 27, 2019 · 1 comment

Comments

@oddball
Copy link

oddball commented Nov 27, 2019

Just tried to use this package, but ran into a problem.

I tried

const Swift = require("swift-mock");
const swift = new Swift();

But it fails with something like

SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at new Swift (/whatever/node_modules/swift-mock/lib/swift.js:19:33)

I had a look in the code. At

this.fieldPatterns = JSON.parse(patterns);

JSON.parse is done on patterns. But patterns already is an object and it fails.

Same thing at

this.fieldPatterns = fieldPatterns ? JSON.parse(fieldPatterns) : patterns;

After I changed that I could parse my Swift file. I am sitting on

npx node --version
v10.15.1
@oddball
Copy link
Author

oddball commented Sep 30, 2020

Fix for it exist here CaptorAB@a70690e

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