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' } { #category : 'converting' }
Tiddler >> asJson [ Tiddler >> asJson [
^ STONJSON toStringPretty: self asDictionary ^ STON toStringPretty: { self asDictionary }
]
{ #category : 'converting' }
Tiddler >> asJsonString [
^ STONJSON toStringPretty: self asDictionary
] ]
{ #category : 'accessing' } { #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' } { #category : 'accessing' }
Tiddler >> bag [ Tiddler >> bag [
^ bag ^ bag

View File

@ -16,9 +16,15 @@ Class {
{ #category : 'accessing' } { #category : 'accessing' }
TiddlyWiki >> exportSTONTiddlersFile [ TiddlyWiki >> exportSTONTiddlersFile [
| stonFile | | stonFile output |
stonFile := self tiddlersJSONFile withoutExtension, 'ston'. 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' } { #category : 'accessing' }