How to write nested JSON structure in tiddler fields, like Array or Object

No, jsontiddler Macro will still return stringified field value:

I think this basically means I need to write a plugin for the process of

  1. inputting json using the extended form UI
  2. using JSON filters we already have to write filters in the wiki
  3. exporting JSON based on a schema,that will tells which field contains JSON content.

And in the tiddler, JSON Object fields will still keep being stringified.

Tiddler field values are always strings. Internally, the “list” field is modelled as an array of strings. It sounds like you want tiddlers to be stored such that the field value is arbitrary JSON. That would be a deep change to the core.

Could you go back to what you’re trying to do? If I understand correctly, you want a user to be able to fill in some input boxes, and then generate a block of JSON that incorporates the values entered by the user? What’s the next step for the JSON? Do you want to export it for processing elsewhere, or POST it to an API endpoint?

I will load those JSON to a game engine, possibly by exporting tiddlers as JSON-LD to SoLiD server using solid-tiddlywiki-syncadaptor.
Then my game engine will load JSON-LD from SoLiD, and run procedural content generations scripts, just like how DrawfFortress uses its data to generate a game world dynamically.

I’m using JSON to describe all possible things in the game world, so some fields need to be arbitrary JSON to gain enough expressibility.

Hi @linonetwo it sounds like perhaps the problem is that you’re trying to reuse TiddlyWiki’s existing JSON export format. There’s a fundamental incompatibility that stops that from working: TiddlyWiki requires that fields be strings.

So, I think the workaround would be to make your own template that exports the fields you want as text within the JSON framework, as I showed above.

  • @linonetwo Not only as suggested by @jeremyruston but keep the data as a regular tiddler to maximise how you can act on and manipulate the tiddler with standard tools.
  • Then in the “your own template that exports the fields” allow “named” fields to use one form of encoding over the other.
    • The same could be done for static content that the server also publishes, so the alternate format JSON data is found at a URL.
      • I cant find my current documentation on publishing “static tiddlers” along side the interactive Node wiki, with this you need only change the template.
  • my point is keep your data in the native form and only use an alternative when needed such as at export, or publishing.
    • If you need it all the time, add a viewTemplate