Skip to content

it will throw exception when json file multiple line  #22

Description

@zewait
{ Error: Command failed: ./node_modules/.bin/mock-api-server --port 7000                                                                                                                                  [10/5588]
undefined:1
    "title":"学习Ruby - 元编程",
           ^

SyntaxError: Unexpected token : in JSON at position 11
    at Object.parse (native)
    at module.exports (/home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/lib/parse_json_files.js:28:17)
    at /home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/lib/server.js:81:67
    at /home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/node_modules/async/lib/async.js:533:17
    at /home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/node_modules/async/lib/async.js:119:25
    at /home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/node_modules/async/lib/async.js:24:16
    at /home/wait/workspace/js/simple_frontend/node_modules/mock-api-server/node_modules/async/lib/async.js:530:21
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)

    at ChildProcess.exithandler (child_process.js:202:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:492:12)
  killed: false,
  code: 1,
  signal: null,
  cmd: './node_modules/.bin/mock-api-server --port 7000' }

my json file

test/mock-api/GET/v1/foobizzle.json

[
  {
    "title":"学习Ruby - 元编程",
    "done": true
  },
  {
    "title": "研究可持续集成",
    "done": false
  },
  {
    "title": "探究单元测试",
    "done": false
  }
]

single line is no problem

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions