mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-18 02:09:43 +00:00
28 lines
571 B
JavaScript
28 lines
571 B
JavaScript
|
/*\
|
||
|
title: $:/core/modules/filters/format/json.js
|
||
|
type: application/javascript
|
||
|
module-type: formatfilteroperator
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter function
|
||
|
*/
|
||
|
exports.json = function(source,operand,options) {
|
||
|
var results = [],
|
||
|
spaces = null;
|
||
|
if(operand) {
|
||
|
spaces = /^\d+$/.test(operand) ? parseInt(operand,10) : operand;
|
||
|
}
|
||
|
source(function(tiddler,title) {
|
||
|
var data = $tw.utils.parseJSONSafe(title);
|
||
|
results.push(JSON.stringify(data,null,spaces));
|
||
|
});
|
||
|
return results;
|
||
|
};
|
||
|
|
||
|
})();
|