mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-19 16:55:14 +00:00
Introduce JSON parse utility function with error handling (#6401)
* Introduce JSON parse utility function with error handling Fixes #6400 * Fix typo
This commit is contained in:
@@ -17,16 +17,13 @@ exports["application/x-tiddler-html-div"] = function(text,fields) {
|
||||
};
|
||||
|
||||
exports["application/json"] = function(text,fields) {
|
||||
var incoming,
|
||||
results = [];
|
||||
try {
|
||||
incoming = JSON.parse(text);
|
||||
} catch(e) {
|
||||
incoming = [{
|
||||
title: "JSON error: " + e,
|
||||
text: ""
|
||||
}]
|
||||
}
|
||||
var results = [],
|
||||
incoming = $tw.utils.parseJSONSafe(text,function(err) {
|
||||
return [{
|
||||
title: "JSON error: " + err,
|
||||
text: ""
|
||||
}];
|
||||
});
|
||||
if(!$tw.utils.isArray(incoming)) {
|
||||
incoming = [incoming];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user