Folks,
This was corrected and now works, use the macro and provide the input.txt, but only with the help of @EricShulman and @Mark_S thanks gentlemen.
\define temp() $:/temp/text-to-json-tiddler
\define text-to-json(tiddler)
<$button >Convert $tiddler$ to $tiddler$.json
<$action-createtiddler $basetitle="$tiddler$.json" $savetitle=<<temp>> type="application/json"/>
<$list filter="
[[$tiddler$]get[text]splitregexp[\n]!is[blank]]" variable="row-content">
<$action-setfield
$tiddler={{$:/temp/text-to-json-tiddler}}
$index=<<row-content>>
$value=""
/>
</$list>
<$action-deletetiddler $tiddler=<<temp>>/>
</$button>
\end
<<text-to-json "input.txt">>
Original Post
Once resolved this will be a how to instruction. I will edit the lead post. However I cant get it to work at present. Any help appreciated.
\define text-to-json(tiddler)
<$fieldmangler>
<$button>
Convert $tiddler$ to $tiddler$.json
<$action-createtiddler $basetitle="$tiddler$.json" $savetitle="$:/temp/text-to-json-tiddler" type="application/json">
<$list filter="[[$tiddler$]get[text]splitregexp[\n]]" variable=row-content>
<$action-setfield
$tiddler={{$:/temp/text-to-json-tiddler}}
$index=<<row-content>>
$value="dummy"
/>
</$list>
</$button>
</$fieldmangler>
Show preview? change to filter?
<$list filter="[[$:/temp/text-to-json-tiddler]has[title]]">{{||$:/core/ui/Buttons/edit}} <$link/> {{||$:/core/ui/Buttons/delete}}</$list>
\end
<<text-to-json "input.txt">>
In the above example the input.txt has a number of lines containing single words. I want to use these to create a JSON file so later I can check if a given word matches one in the data tiddler.
Currently the result is only an empty tiddler with type=application/json
- Could it be the fieldmangler widget, is it needed is it in the correct place.
- have I a syntax error
- is the create tiddler too soon for the add indexes to work?
Thanks in advance!