Guest User

Untitled

a guest
Oct 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. fs = require("fs")
  2.  
  3. readJSON = (path, cb) ->
  4. fs.readFile path, "utf8", (err, data) ->
  5. if err
  6. return cb err
  7.  
  8. try
  9. json = JSON.parse(data)
  10. catch error
  11. return cb error
  12.  
  13. cb null, json
  14.  
  15.  
  16. filename = "wellformed.json" #"malformed.json"
  17.  
  18. readJSON filename, (err, data) ->
  19. console.log data
  20.  
  21. console.log "end"
Add Comment
Please, Sign In to add comment