Improving data serialization and making it more diff friendly.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-09-08 17:52:03 -05:00
parent 27eb70e928
commit d7da993cd0
2 changed files with 29 additions and 4 deletions

View File

@ -50,8 +50,13 @@ Tiddler >> asDictionary [
]
{ #category : 'converting' }
Tiddler >> asJson [
^ STONJSON toStringPretty: self asDictionary
Tiddler >> asJson [
^ STON toStringPretty: { self asDictionary }
]
{ #category : 'converting' }
Tiddler >> asJsonString [
^ STONJSON toStringPretty: self asDictionary
]
{ #category : 'accessing' }
@ -60,6 +65,20 @@ Tiddler >> asJsonTempFile [
]
{ #category : 'accessing' }
Tiddler >> asStonStringPretty [
| output temp |
temp := self.
temp wiki: nil.
output := '' writeStream.
(STON writer on: output)
newLine: String crlf;
prettyPrint: true;
keepNewLines: true;
nextPut: temp.
^ output contents
]
{ #category : 'accessing' }
Tiddler >> bag [
^ bag

View File

@ -16,9 +16,15 @@ Class {
{ #category : 'accessing' }
TiddlyWiki >> exportSTONTiddlersFile [
| stonFile |
| stonFile output |
stonFile := self tiddlersJSONFile withoutExtension, 'ston'.
^ MarkupFile exportAsFileOn: stonFile containing:(STON toStringPretty: self)
output := '' writeStream.
(STON writer on: output )
newLine: String lf;
prettyPrint: true;
keepNewLines: true;
nextPut: self.
^ MarkupFile exportAsFileOn: stonFile containing:self
]
{ #category : 'accessing' }