@@ -1956,6 +1956,8 @@ job_start({command} [, {options}]) Job start a job
19561956job_status({job} ) String get the status of a job
19571957job_stop({job} [, {how} ]) Number stop a job
19581958join( {list} [, {sep} ]) String join {list} items into one String
1959+ jsdecode( {string} ) any decode JS style JSON
1960+ jsencode( {expr} ) String encode JS style JSON
19591961jsondecode( {string} ) any decode JSON
19601962jsonencode( {expr} ) String encode JSON
19611963keys( {dict} ) List keys in {dict}
@@ -2439,7 +2441,6 @@ bufwinnr({expr}) *bufwinnr()*
24392441 | :wincmd | .
24402442 Only deals with the current tab page.
24412443
2442-
24432444byte2line({byte} ) *byte2line()*
24442445 Return the line number that contains the character at byte
24452446 count {byte} in the current buffer. This includes the
@@ -2688,7 +2689,7 @@ ch_open({address} [, {argdict}]) *ch_open()*
26882689
26892690 If {argdict} is given it must be a | Dictionary | . The optional
26902691 items are:
2691- mode "raw" or "json".
2692+ mode "raw", "js" or "json".
26922693 Default "json".
26932694 callback function to call for requests with a zero
26942695 sequence number. See | channel-callback | .
@@ -2702,10 +2703,12 @@ ch_open({address} [, {argdict}]) *ch_open()*
27022703 {only available when compiled with the | +channel | feature}
27032704
27042705ch_sendexpr({handle} , {expr} [, {callback} ]) *ch_sendexpr()*
2705- Send {expr} over JSON channel {handle} . See | channel-use | .
2706+ Send {expr} over channel {handle} . The {expr} is encoded
2707+ according to the type of channel. The function cannot be used
2708+ with a raw channel. See | channel-use | . *E912*
27062709
27072710 When {callback} is given returns immediately. Without
2708- {callback} waits for a JSON response and returns the decoded
2711+ {callback} waits for a response and returns the decoded
27092712 expression. When there is an error or timeout returns an
27102713 empty string.
27112714
@@ -2717,8 +2720,10 @@ ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()*
27172720 {only available when compiled with the | +channel | feature}
27182721
27192722ch_sendraw({handle} , {string} [, {callback} ]) *ch_sendraw()*
2720- Send {string} over raw channel {handle} . See | channel-raw | .
2721- Works like | ch_sendexpr() | , but does not decode the response.
2723+ Send {string} over channel {handle} .
2724+ Works like | ch_sendexpr() | , but does not encode the request or
2725+ decode the response. The caller is responsible for the
2726+ correct contents. See | channel-use | .
27222727
27232728 {only available when compiled with the | +channel | feature}
27242729
@@ -4381,17 +4386,33 @@ join({list} [, {sep}]) *join()*
43814386 converted into a string like with | string() | .
43824387 The opposite function is | split() | .
43834388
4389+ jsdecode({string} ) *jsdecode()*
4390+ This is similar to | jsondecode() | with these differences:
4391+ - Object key names do not have to be in quotes.
4392+ - Empty items in an array (between two commas) are allowed and
4393+ result in v:none items.
4394+
4395+ jsencode({expr} ) *jsencode()*
4396+ This is similar to | jsonencode() | with these differences:
4397+ - Object key names are not in quotes.
4398+ - v:none items in an array result in an empty item between
4399+ commas.
4400+ For example, the Vim object:
4401+ [1,v:none,{"one":1}],v:none ~
4402+ Will be encoded as:
4403+ [1,,{one:1},,] ~
4404+ While jsonencode() would produce:
4405+ [1,null,{"one":1},null] ~
4406+ This encoding is valid for JavaScript. It is more efficient
4407+ than JSON, especially when using an array with optional items.
4408+
4409+
43844410jsondecode({string} ) *jsondecode()*
43854411 This parses a JSON formatted string and returns the equivalent
43864412 in Vim values. See | jsonencode() | for the relation between
43874413 JSON and Vim values.
43884414 The decoding is permissive:
43894415 - A trailing comma in an array and object is ignored.
4390- - An empty item in an array, two commas with nothing or white
4391- space in between, results in v:none.
4392- - When an object member name is not a string it is converted
4393- to a string. E.g. the number 123 is used as the string
4394- "123".
43954416 - More floating point numbers are recognized, e.g. "1." for
43964417 "1.0".
43974418 The result must be a valid Vim type:
@@ -4413,7 +4434,7 @@ jsonencode({expr}) *jsonencode()*
44134434 used recursively: {}
44144435 v:false "false"
44154436 v:true "true"
4416- v:none nothing
4437+ v:none "null"
44174438 v:null "null"
44184439 Note that using v:none is permitted, although the JSON
44194440 standard does not allow empty items. This can be useful for
0 commit comments