Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 執行時將測試陣列的字串依序轉成 list 或 json object
- const util = require('util');
- const jsonParser = require('./jsonParser');
- function main() {
- const parserTestArr = [' [ 10 , 20.0, 0.2 ] ', ' [ 10, 20.0, "hello", 0.2 ] ',
- ' { \"foo\": \"bar\", \"hello\" : 100 }', '{ \"key\": { \"foo\": \"bar\", \"hello\" : 100 } }'];
- const JsonParser = new jsonParser();
- for (const testStr of parserTestArr) {
- const parsedResult = JsonParser.parse(testStr);
- console.log(`Input: ${testStr}, parsed result: ${util.inspect(parsedResult, false, null)}`);
- }
- console.log('Job is done!');
- }
- main();
Add Comment
Please, Sign In to add comment