Hi Mario

> Jeremy did suggest a format to reference JSON elements from wikitext in
an issue:

Just checking: did you see my post earlier in this thread?

I think you are suggesting a number of more or less separable things:

* That the result of retrieving a value from a tiddler dictionary should
return a tiddler, rather than just a string of text as it does at the moment
* That we should use the existing wikitext heading syntax to represent
hashmap entries

Is that right? I'm not sure that I fully understand.

Best wishes

Jeremy



On Thu, Feb 27, 2014 at 3:26 PM, PMario <[email protected]> wrote:

> Jeremy did suggest a format to reference JSON elements from wikitext in an
> issue:
>
> There's the issue:
> Explore using JSON Pointers to reference data within data tiddlers:
> https://github.com/Jermolene/TiddlyWiki5/issues/411
>
> Here's the draft:
> JavaScript Object Notation (JSON) Pointer
> http://tools.ietf.org/html/rfc6901
>
> -----------
>
> I'm not sure, if it is also meant to create a JSON structure, but it may
> be possible.
>
> a pointer always starts with a slash "/"
>
> /title: tiddler title
> /tags/0: tag1
> /tags/1: tag2
> /text:
> multi line text by default
> second line
>
> empty line above
> /fields/myfield: field value.
>
>
> I don't like the readability above.
> So may be if trailing empty lines are removed:
>
> /title: tiddler title
>
> /tags/0: tag1
>
> /tags/1: tag2
>
> /text:
> multi line text by default
> second line
>
> empty line above
>
> /fields/myfield: field value.
>
> ---------------
> If I see this I'd suggest a Syntax, like this:
>
> The tiddler title is the object, that contains the whole structure.
>
> JSON Pointer eg:
> /JPointerTest returns {"JPointerTest":{  ....  }}
>
> JPointerTest tiddler contains:
>
> ! myFirstObject
>
> Some multiline text.
> second line
>
> empty line above
>
> ! key Value Pairs
>
> key1:value1 ... a key value pair
> key2:value2
> key3:value3
>
> ---------------
> So if I request
> /JPointerTest   ... I get:
>
> {fields:
>   {
>   "title":"JPointerTest",
>   "tags":["tag1", "tag2"],
>   "text":{"myFirstObject":
>              ["\n", "Some multiline text.\n", "second line\n", "\n",
> "empty line above\n"],
>           "key Value Pairs":
>              [{"key1":"value1 ... a key value pair"}, {"key2":"value2"},
> {"key3":"value3"}    ]
>          },
>   }
> }
>
> So imo the parser, to create a structure like this would be very simple.
> ...
>
>  - Get the tiddler with: var tid = $tw.getTiddler("JPointerTest")
>  - Check if it is a type: application/x-tiddler-dictionary
>  - Create a JSONdict = { "fields": {} }
>  - Assign the title: JSONdict.fields.title = tid.fields.title
>  - get the tags: JSONdict.fields.tags = tid.fields.tags
>
>  - get the text and parse it to JSON described above: JSONdict.fields.t =
> createJsonFromText(tid.fields.text)
>
> done.
>
> The "createJsonFromText()" functions would need some love, but imo is
> simple too.
>  - start with a line parser
>
>  - read a line
>   - check if the line starts an object .. if yes create the object
>   - read the next lines and add it to the object as an array element.
>     - check the element if it contains a "key : value" element
>     - if yes store the k/v-element into the array.
>
>  - read lines until end of text or new object detected
>  - read line until finieshed
>
> The advantage of my sytax is, that it is valid TW syntax. Even if it would
> be only a subset. So it would be perfectly fine to render it as TW syntax
> and reference it with JSON Pointers.
>
> have fun!
> mario
>
> [1] http://tools.ietf.org/html/rfc6901#section-6
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" 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 http://groups.google.com/group/tiddlywikidev.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jeremy Ruston
mailto:[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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 http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to