From a6c780f16fc581d1cc99f75fc77687b5f95276ba Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Mon, 9 Apr 2018 16:14:55 +0800 Subject: [PATCH] fix: markdown json-parse --- common/markdown.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/markdown.js b/common/markdown.js index 6de7b6bb..da71c8f1 100644 --- a/common/markdown.js +++ b/common/markdown.js @@ -1,6 +1,13 @@ const schema = require('./shema-transformTo-table.js'); const _ = require('underscore'); +const json_parse = function(json){ + try{ + return JSON.parse(json); + }catch(err){ + return {}; + } +} const messageMap = { desc: '备注', default: '实例', @@ -206,7 +213,7 @@ function tableBody(dataSource, columns, level) { function createSchemaTable(body) { let template = ``; - let dataSource = schema.schemaTransformToTable(JSON.parse(body)); + let dataSource = schema.schemaTransformToTable(json_parse(body)); template += `