As a workaround I created a custom exporter:

title: $:/.mau/exporters/json
description: Export text as JSON
extension: .json

\define renderContent()
{{{ $(exportFilter)$ +[limit[1]] ||$:/.mau/templates/json}}}
\end
<$importvariables filter="[[$:/core/ui/PageMacros]] 
[all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]"><<renderContent>></$importvariables>

title: $:/.mau/templates/json

<$view field="text" format="plainwikified" />

It works, but it is not exactly what I was looking for.

   - First, it is not autonomous. It requires the user to click a button to 
   trigger the export.
   - It is not exactly a json exporter, but a "text only" exporter. It 
   exports just the text field, despite its content. Applied to an 
   "application/json" tiddler it actually creates a JSON file.

I use this button to trigger the export:

title: $:/.mau/json-export-button

<$button class="tc-btn-invisible tc-tiddlylink">
{{$:/core/images/export-button}} Export text as JSON
<$action-sendmessage $message="tm-download-file" 
$param="$:/.mau/exporters/json" exportFilter="""[[sample.json]]""" 
filename="sample.json"/>
</$button>

And this is the sample.json I used to test the exporter:

title: sample.json
type: application/json

{
    "album": "The Dark Side of the Moon",
    "artist": "Pink Floyd",
    "year": "1973",
    "tracks": [
        "Speak to Me",
        "Breathe",
        "On the Run",
        "Time",
        "The Great Gig in the Sky",
        "Money",
        "Us and Them",
        "Any Colour You Like",
        "Brain Damage",
        "Eclipse"
    ]
}

Happy to share this workaround with the community. Still searching for a 
way to save "application/json" tiddler as .JSON + .JSON.META. Any idea? 
Maybe some options in tiddlywiki.info?

Thanks,

)+(

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e3c9689a-debe-4453-aa2e-068f7c058e35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to