mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
rename jsonvariables back to jsonvariable
This commit is contained in:
parent
aa8ccfe8f9
commit
432c6af2a2
@ -1,5 +1,5 @@
|
||||
/*\
|
||||
title: $:/core/modules/filters/jsonvariables.js
|
||||
title: $:/core/modules/filters/jsonvariable.js
|
||||
type: application/javascript
|
||||
module-type: filteroperator
|
||||
|
||||
@ -16,7 +16,7 @@ Display as JSON with basic formatting
|
||||
/*
|
||||
Export our filter function
|
||||
*/
|
||||
exports.jsonvariables = function(source,operator,options) {
|
||||
exports.jsonvariable = function(source,operator,options) {
|
||||
var results = [],
|
||||
widget = options.widget;
|
||||
// "replacer" must be defined, otherwise JSON.stringify will throw a circular reference error RSOD
|
||||
|
@ -56,7 +56,7 @@ tags: $:/tags/Global
|
||||
<li>
|
||||
<code title={{$:/language/Search/Variables/Signature}}><$text text=<<wlf.dv-formattedVar>>/></code><br/>
|
||||
<% if [<wlf.dv-formattedVar>prefix[\function]] %>
|
||||
<pre title={{$:/language/Search/Variables/Function/Definition}}><code><$text text={{{ [<varname>jsonvariables[]jsonextract[srcVariable],[value]] }}}/></code></pre>
|
||||
<pre title={{$:/language/Search/Variables/Function/Definition}}><code><$text text={{{ [<varname>jsonvariable[]jsonextract[srcVariable],[value]] }}}/></code></pre>
|
||||
<% endif %>
|
||||
<pre title={{$:/language/Search/Variables/Content}}><code><$text text={{{ [<varname>getvariable[]] }}}/></code></pre>
|
||||
</li>
|
||||
@ -235,7 +235,7 @@ tags: $:/tags/Global
|
||||
<<dv-info>>
|
||||
<% endif %>
|
||||
<% if [<varname>prefix[\function]] %>
|
||||
<$codeblock code={{{ [<varname>jsonvariables[]jsonextract[srcVariable],[value]] }}}/>
|
||||
<$codeblock code={{{ [<varname>jsonvariable[]jsonextract[srcVariable],[value]] }}}/>
|
||||
<% endif %>
|
||||
<pre tabindex="0" title={{$:/language/Search/Variables/Content}}><code><$text text={{{ [<varname>getvariable[]] }}}/></code></pre>
|
||||
</blockquote>
|
||||
|
@ -1,15 +1,15 @@
|
||||
created: 20240506132850677
|
||||
modified: 20240523052607425
|
||||
tags: [[Operator Examples]] [[jsonvariables Operator]]
|
||||
title: jsonvariables Operator (Examples)
|
||||
tags: [[Operator Examples]] [[jsonvariable Operator]]
|
||||
title: jsonvariable Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The following example shows the "internal" structure of the `fn.test` function defined in <<.olink jsonvariables>> operator
|
||||
The following example shows the "internal" structure of the `fn.test` function defined in <<.olink jsonvariable>> operator
|
||||
|
||||
<<.example 1 """\procedure testProc() [[aa aa]] bb
|
||||
\function fn.test(splitChar:" " not-used) [enlist<testProc>format:titlelist[]]
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]]}}}/></code></pre>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]]}}}/></code></pre>
|
||||
""">>
|
||||
|
||||
The following example shows the same structure ''pretty printed'' using the <<.olink format>> filter operator
|
||||
@ -19,7 +19,7 @@ The following example shows the same structure ''pretty printed'' using the <<.o
|
||||
|
||||
\function tab() [charcode[9]]
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]format:json<tab>]}}}/></code></pre>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]format:json<tab>]}}}/></code></pre>
|
||||
""">>
|
||||
|
||||
The following example extracts the ''function definition'' using the <<.olink jsonextract>> filter operator
|
||||
@ -27,7 +27,7 @@ The following example extracts the ''function definition'' using the <<.olink js
|
||||
<<.example 3 """\procedure testProc() [[aa aa]] bb
|
||||
\function fn.test(splitChar:" " not-used) [enlist<testProc>format:titlelist[]]
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]jsonextract[srcVariable],[value]]}}}/></code></pre>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]jsonextract[srcVariable],[value]]}}}/></code></pre>
|
||||
""">>
|
||||
|
||||
The following example extracts the `srcVariables.params` with pretty printing using <<.olink jsonextract>>
|
||||
@ -37,5 +37,5 @@ The following example extracts the `srcVariables.params` with pretty printing us
|
||||
|
||||
\function tab() [charcode[9]]
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]jsonextract[srcVariable],[params]format:json<tab>]}}}/></code></pre>""">>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]jsonextract[srcVariable],[params]format:json<tab>]}}}/></code></pre>""">>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
caption: jsonvariables
|
||||
caption: jsonvariable
|
||||
created: 20240506131935424
|
||||
modified: 20240506151517068
|
||||
op-input: a selection variable names
|
||||
@ -7,7 +7,7 @@ op-parameter: one or more indexes of the property to retrieve
|
||||
op-parameter-name: R
|
||||
op-purpose: retrieve the JSON string from a ~TiddlyWiki variable
|
||||
tags: [[Filter Operators]] [[JSON Operators]]
|
||||
title: jsonvariables Operator
|
||||
title: jsonvariable Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
\procedure testProc() [[aa aa]] bb
|
||||
@ -16,9 +16,9 @@ type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.3.4">>
|
||||
|
||||
The <<.op jsonvariables>> operator is used to retrieve variables as JSON substrings. See also the following related operators:
|
||||
The <<.op jsonvariable>> operator is used to retrieve variables as JSON substrings. See also the following related operators:
|
||||
|
||||
Properties within a JSON object are identified by a sequence of indexes. In the following example, we use a procedure: `testProc` and a function: `fn.test` to show the possibilities of <<.op jsonvariables>>. The `tab`-function is needed for the <<.olink format>> ooperator, which is used to "pretty-print" the output.
|
||||
Properties within a JSON object are identified by a sequence of indexes. In the following example, we use a procedure: `testProc` and a function: `fn.test` to show the possibilities of <<.op jsonvariable>>. The `tab`-function is needed for the <<.olink format>> ooperator, which is used to "pretty-print" the output.
|
||||
|
||||
```
|
||||
\procedure testProc() [[aa aa]] bb
|
||||
@ -26,12 +26,12 @@ Properties within a JSON object are identified by a sequence of indexes. In the
|
||||
|
||||
\function tab() [charcode[9]]
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]format:json<tab>]}}}/></code></pre>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]format:json<tab>]}}}/></code></pre>
|
||||
```
|
||||
|
||||
Which results to:
|
||||
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariables[]format:json<tab>]}}}/></code></pre>
|
||||
<pre><code><$text text={{{[[fn.test]jsonvariable[]format:json<tab>]}}}/></code></pre>
|
||||
|
||||
Also see:
|
||||
|
||||
@ -42,4 +42,4 @@ Also see:
|
||||
|
||||
Every TW variable has this internal structure, which we can use to extract the info we need.
|
||||
|
||||
!! <<.operator-examples "jsonvariables">>
|
||||
!! <<.operator-examples "jsonvariable">>
|
@ -1,35 +1,35 @@
|
||||
created: 20240506101435113
|
||||
modified: 20240506140610448
|
||||
tags:
|
||||
title: test-jsonvariables-conat
|
||||
title: test-jsonvariable-conat
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
''Nice to have''
|
||||
|
||||
<<.example 1 """\function tab() [charcode[9]]
|
||||
|
||||
<pre><$text text={{{[[.concat]jsonvariables[]]}}}/></pre>
|
||||
<pre><$text text={{{[[.concat]jsonvariable[]]}}}/></pre>
|
||||
""">>
|
||||
|
||||
''Human readable version''
|
||||
|
||||
<<.example 2 """\function tab() [charcode[9]]
|
||||
|
||||
<pre><$text text={{{[[.concat]jsonvariables[]format:json<tab>]}}}/></pre>
|
||||
<pre><$text text={{{[[.concat]jsonvariable[]format:json<tab>]}}}/></pre>
|
||||
""">>
|
||||
|
||||
''Function definition''
|
||||
|
||||
<<.example 3 """\function tab() [charcode[9]]
|
||||
|
||||
<pre><$text text={{{[[.concat]jsonvariables[]jsonextract[srcVariable],[value]format:json<tab>]}}}/></pre>
|
||||
<pre><$text text={{{[[.concat]jsonvariable[]jsonextract[srcVariable],[value]format:json<tab>]}}}/></pre>
|
||||
""">>
|
||||
|
||||
''Get parameters''
|
||||
|
||||
<<.example 4 """\function tab() [charcode[9]]
|
||||
|
||||
<pre><$text text={{{[[.concat]jsonvariables[]jsonextract[srcVariable],[params]format:json<tab>]}}}/></pre>
|
||||
<pre><$text text={{{[[.concat]jsonvariable[]jsonextract[srcVariable],[params]format:json<tab>]}}}/></pre>
|
||||
""">>
|
||||
|
||||
''Expected''
|
||||
|
Loading…
Reference in New Issue
Block a user