1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00

Fix JSON deserialiser to allow all fields

Previously we were filtering to a small set of known fields (which was
implemented at the beginning of TW5 as part of the build process for
TW2).
This commit is contained in:
Jermolene 2014-11-13 16:04:30 +00:00
parent 4dec771c20
commit 4bf6fe7fe9

View File

@ -72,21 +72,21 @@ exports["application/x-tiddler-html-div"] = function(text,fields) {
};
exports["application/json"] = function(text,fields) {
var tiddlers = JSON.parse(text),
result = [],
getKnownFields = function(tid) {
var fields = {};
"title text created creator modified modifier type tags".split(" ").forEach(function(value) {
if(tid[value] !== null) {
fields[value] = tid[value];
var incoming = JSON.parse(text),
results = [];
if($tw.utils.isArray(incoming)) {
for(var t=0; t<incoming.length; t++) {
var incomingFields = incoming[t],
fields = {};
for(var f in incomingFields) {
if(typeof incomingFields[f] === "string") {
fields[f] = incomingFields[f];
}
});
return fields;
};
for(var t=0; t<tiddlers.length; t++) {
result.push(getKnownFields(tiddlers[t]));
}
results.push(fields);
}
}
return result;
return results;
};
/*