Guest User

Untitled

a guest
Mar 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // 執行時將測試陣列的字串依序轉成 list 或 json object
  2. const util = require('util');
  3. const jsonParser = require('./jsonParser');
  4.  
  5. function main() {
  6. const parserTestArr = [' [ 10 , 20.0, 0.2 ] ', ' [ 10, 20.0, "hello", 0.2 ] ',
  7. ' { \"foo\": \"bar\", \"hello\" : 100 }', '{ \"key\": { \"foo\": \"bar\", \"hello\" : 100 } }'];
  8.  
  9. const JsonParser = new jsonParser();
  10. for (const testStr of parserTestArr) {
  11. const parsedResult = JsonParser.parse(testStr);
  12. console.log(`Input: ${testStr}, parsed result: ${util.inspect(parsedResult, false, null)}`);
  13. }
  14. console.log('Job is done!');
  15. }
  16.  
  17. main();
Add Comment
Please, Sign In to add comment