2d(1-5): To JSON, Wains
+to-wain:format
+to-wain:formatCord to line list
Convert txt to a wain, breaking on newline characters.
Accepts
txt is a @t.
Produces
A $wain, which is a (list @t).
Source
++ to-wain
|= txt=cord
^- wain
=/ len=@ (met 3 txt)
=/ cut =+(cut -(a 3, c 1, d txt))
=/ sub sub
=| [i=@ out=wain]
|- ^+ out
=+ |- ^- j=@
?: ?| =(i len)
=(10 (cut(b i)))
==
i
$(i +(i))
=. out :_ out
(cut(b i, c (sub j i)))
?: =(j len)
(flop out)
$(i +(j))Examples
+of-wain:format
+of-wain:formatLine list to cord
Convert tez to a cord, separating each line with a newline character.
Accepts
tez is a $wain, which is a (list @t).
Produces
A @t.
Source
Examples
+of-wall:format
+of-wall:formatLine list to tape
Convert .a to a tape, separating each line with a newline character.
Accepts
.a is a +wall, which is a (list tape)
Produces
A $tape.
Source
Examples
+json-rn:format
+json-rn:formatjson to rn parser
This function is used internally by +ne and would not typically be used directly. It is a $rule that parses a real number string to a +rn in a unit.
Accepts
A $nail containing a real number.
Produces
An $edge containing a (unit rn).
Source
Examples
+enjs:format
+enjs:formatContainer arm for JSON encoders
The +core inside this arm contains a collection of functions for converting various types of data to $json. The $json type is defined in lull.hoon as:
This container arm doesn't do anything itself. The different $json encoding functions are documented individually below.
+frond:enjs:format
+frond:enjs:formatObject from key-value pair
Produces a $json object containing .q with a key of .p.
Accepts
.p is a @t key.
.q is any $json.
Produces
A $json object.
Source
Examples
+pairs:enjs:format
+pairs:enjs:formatObject from key-value pair list
Produces a $json object containing each key-value pair in list .a.
Accepts
.a is a (list [@t json]).
Produces
A $json object.
Source
Examples
+tape:enjs:format
+tape:enjs:formatString from tape
Converts .a into a $json string.
Accepts
.a is a $tape.
Produces
A $json string.
Source
Examples
+wall:enjs:format
+wall:enjs:formatString from wall
Converts .a to a $json string, separating lines with newline characters.
Accepts
.a is a +wall, which is a (list tape).
Produces
A $json string.
Source
Examples
+ship:enjs:format
+ship:enjs:formatString* from ship
Convert ship .a to a $json string*.
Note: Currently this produces a $json number rather than string, but with the ship name rendered as text rather than a number. This is for Landscape performance reasons and may be reverted at some point.
Accepts
.a is a @p.
Produces
A $json string number but with the @p rendered as text rather than a number.
Source
Examples
+numb:enjs:format
+numb:enjs:formatNumber from unsigned
Convert .a to a $json number.
Accepts
.a is a @u
Produces
A $json number.
Source
Examples
+sect:enjs:format
+sect:enjs:formatSeconds timestamp
Convert time .a to a Unix seconds timestamp in a $json number.
Accepts
.a is a @da.
Produces
A $json number.
Source
Examples
+time:enjs:format
+time:enjs:formatMillisecond timestamp
Convert time .a to a Unix milliseconds timestamp in a $json number.
Accepts
.a is a @da.
Produces
A $json number.
Source
Examples
+path:enjs:format
+path:enjs:formatString from path
Encode path .a in a $json string.
Accepts
.a is a $path
Produces
A $json string.
Source
Examples
+tank:enjs:format
+tank:enjs:formatTank as string array
Convert tank .a into a $json array of strings. The tank is passed through +wash with a maximum width of 80 characters specified, so may be split into multiple strings if it's too wide.
Accepts
.a is a $tank
Produces
A $json array of strings.
Source
Examples
Last updated