Hi Bram and list,
I think The following built-in functions names visibility not good.
jsonencode()
jsondecode()
jsencode()
jsdecode()
I suggest that we rename these function names to:
json_encode()
json_decode()
js_encode()
js_decode()
Somehow, I wrote a patch.
I think possible in time. :-)
How about this?
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt
index 2368750..6753165 100644
--- a/runtime/doc/channel.txt
+++ b/runtime/doc/channel.txt
@@ -133,7 +133,7 @@ If {mode} is "json" then a message can be sent synchronously like this: >
This awaits a response from the other side.
When {mode} is "js" this works the same, except that the messages use
-JavaScript encoding. See |jsencode()| for the difference.
+JavaScript encoding. See |js_encode()| for the difference.
To send a message, without handling a response: >
call ch_sendexpr(handle, {expr}, 0)
@@ -268,8 +268,8 @@ To send a message and letting the response handled by a specific function,
asynchronously: >
call ch_sendraw(handle, {string}, {callback})
-This {string} can also be JSON, use |jsonencode()| to create it and
-|jsondecode()| to handle a received JSON message.
+This {string} can also be JSON, use |json_encode()| to create it and
+|json_decode()| to handle a received JSON message.
It is not possible to use |ch_sendexpr()| on a raw channel.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 8ebe3ad..a5a3eb0 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1416,7 +1416,7 @@ v:exception The value of the exception most recently caught and not
*v:false* *false-variable*
v:false A Number with value zero. Used to put "false" in JSON. See
- |jsonencode()|.
+ |json_encode()|.
When used as a string this evaluates to "false". >
echo v:false
< false ~
@@ -1556,7 +1556,7 @@ v:mouse_col Column number for a mouse click obtained with |getchar()|.
*v:none* *none-variable*
v:none An empty String. Used to put an empty item in JSON. See
- |jsonencode()|.
+ |json_encode()|.
When used as a number this evaluates to zero.
When used as a string this evaluates to "none". >
echo v:none
@@ -1564,7 +1564,7 @@ v:none An empty String. Used to put an empty item in JSON. See
*v:null* *null-variable*
v:null An empty String. Used to put "null" in JSON. See
- |jsonencode()|.
+ |json_encode()|.
When used as a number this evaluates to zero.
When used as a string this evaluates to "null". >
echo v:null
@@ -1737,7 +1737,7 @@ v:throwpoint The point where the exception most recently caught and not
*v:true* *true-variable*
v:true A Number with value one. Used to put "true" in JSON. See
- |jsonencode()|.
+ |json_encode()|.
When used as a string this evaluates to "true". >
echo v:true
< true ~
@@ -1956,10 +1956,10 @@ job_start({command} [, {options}]) Job start a job
job_status({job}) String get the status of a job
job_stop({job} [, {how}]) Number stop a job
join( {list} [, {sep}]) String join {list} items into one String
-jsdecode( {string}) any decode JS style JSON
-jsencode( {expr}) String encode JS style JSON
-jsondecode( {string}) any decode JSON
-jsonencode( {expr}) String encode JSON
+js_decode( {string}) any decode JS style JSON
+js_encode( {expr}) String encode JS style JSON
+json_decode( {string}) any decode JSON
+json_encode( {expr}) String encode JSON
keys( {dict}) List keys in {dict}
len( {expr}) Number the length of {expr}
libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
@@ -4386,14 +4386,14 @@ join({list} [, {sep}]) *join()*
converted into a string like with |string()|.
The opposite function is |split()|.
-jsdecode({string}) *jsdecode()*
- This is similar to |jsondecode()| with these differences:
+js_decode({string}) *js_decode()*
+ This is similar to |json_decode()| with these differences:
- Object key names do not have to be in quotes.
- Empty items in an array (between two commas) are allowed and
result in v:none items.
-jsencode({expr}) *jsencode()*
- This is similar to |jsonencode()| with these differences:
+js_encode({expr}) *js_encode()*
+ This is similar to |json_encode()| with these differences:
- Object key names are not in quotes.
- v:none items in an array result in an empty item between
commas.
@@ -4401,15 +4401,15 @@ jsencode({expr}) *jsencode()*
[1,v:none,{"one":1}],v:none ~
Will be encoded as:
[1,,{one:1},,] ~
- While jsonencode() would produce:
+ While json_encode() would produce:
[1,null,{"one":1},null] ~
This encoding is valid for JavaScript. It is more efficient
than JSON, especially when using an array with optional items.
-jsondecode({string}) *jsondecode()*
+json_decode({string}) *json_decode()*
This parses a JSON formatted string and returns the equivalent
- in Vim values. See |jsonencode()| for the relation between
+ in Vim values. See |json_encode()| for the relation between
JSON and Vim values.
The decoding is permissive:
- A trailing comma in an array and object is ignored.
@@ -4419,7 +4419,7 @@ jsondecode({string}) *jsondecode()*
- An empty object member name is not allowed.
- Duplicate object member names are not allowed.
-jsonencode({expr}) *jsonencode()*
+json_encode({expr}) *json_encode()*
Encode {expr} as JSON and return this as a string.
The encoding is specified in:
https://tools.ietf.org/html/rfc7159.html
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 66b0aa6..f2d3ac6 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6823,10 +6823,10 @@ job_status() eval.txt /*job_status()*
job_stop() eval.txt /*job_stop()*
join() eval.txt /*join()*
jsbterm-mouse options.txt /*jsbterm-mouse*
-jsdecode() eval.txt /*jsdecode()*
-jsencode() eval.txt /*jsencode()*
-jsondecode() eval.txt /*jsondecode()*
-jsonencode() eval.txt /*jsonencode()*
+js_decode() eval.txt /*js_decode()*
+js_encode() eval.txt /*js_encode()*
+json_decode() eval.txt /*json_decode()*
+json_encode() eval.txt /*json_encode()*
jtags tagsrch.txt /*jtags*
jump-motions motion.txt /*jump-motions*
jumplist motion.txt /*jumplist*
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 583bf99..4b060fe 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -898,8 +898,8 @@ Inter-process communication:
ch_close() close a channel
ch_sendexpr() send a JSON message over a channel
ch_sendraw() send a raw message over a channel
- jsonencode() encode an expression to a JSON string
- jsondecode() decode a JSON string to Vim types
+ json_encode() encode an expression to a JSON string
+ json_decode() decode a JSON string to Vim types
Various: *various-functions*
mode() get current editing mode
diff --git a/src/eval.c b/src/eval.c
index 10f57e8..4e6a53d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -629,10 +629,10 @@ static void f_job_stop(typval_T *argvars, typval_T *rettv);
static void f_job_status(typval_T *argvars, typval_T *rettv);
#endif
static void f_join(typval_T *argvars, typval_T *rettv);
-static void f_jsdecode(typval_T *argvars, typval_T *rettv);
-static void f_jsencode(typval_T *argvars, typval_T *rettv);
-static void f_jsondecode(typval_T *argvars, typval_T *rettv);
-static void f_jsonencode(typval_T *argvars, typval_T *rettv);
+static void f_js_decode(typval_T *argvars, typval_T *rettv);
+static void f_js_encode(typval_T *argvars, typval_T *rettv);
+static void f_json_decode(typval_T *argvars, typval_T *rettv);
+static void f_json_encode(typval_T *argvars, typval_T *rettv);
static void f_keys(typval_T *argvars, typval_T *rettv);
static void f_last_buffer_nr(typval_T *argvars, typval_T *rettv);
static void f_len(typval_T *argvars, typval_T *rettv);
@@ -8213,10 +8213,10 @@ static struct fst
{"job_stop", 1, 2, f_job_stop},
#endif
{"join", 1, 2, f_join},
- {"jsdecode", 1, 1, f_jsdecode},
- {"jsencode", 1, 1, f_jsencode},
- {"jsondecode", 1, 1, f_jsondecode},
- {"jsonencode", 1, 1, f_jsonencode},
+ {"js_decode", 1, 1, f_js_decode},
+ {"js_encode", 1, 1, f_js_encode},
+ {"json_decode", 1, 1, f_json_decode},
+ {"json_encode", 1, 1, f_json_encode},
{"keys", 1, 1, f_keys},
{"last_buffer_nr", 0, 0, f_last_buffer_nr},/* obsolete */
{"len", 1, 1, f_len},
@@ -14487,10 +14487,10 @@ f_join(typval_T *argvars, typval_T *rettv)
}
/*
- * "jsdecode()" function
+ * "js_decode()" function
*/
static void
-f_jsdecode(typval_T *argvars, typval_T *rettv)
+f_js_decode(typval_T *argvars, typval_T *rettv)
{
js_read_T reader;
@@ -14502,20 +14502,20 @@ f_jsdecode(typval_T *argvars, typval_T *rettv)
}
/*
- * "jsencode()" function
+ * "js_encode()" function
*/
static void
-f_jsencode(typval_T *argvars, typval_T *rettv)
+f_js_encode(typval_T *argvars, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = json_encode(&argvars[0], JSON_JS);
}
/*
- * "jsondecode()" function
+ * "json_decode()" function
*/
static void
-f_jsondecode(typval_T *argvars, typval_T *rettv)
+f_json_decode(typval_T *argvars, typval_T *rettv)
{
js_read_T reader;
@@ -14527,10 +14527,10 @@ f_jsondecode(typval_T *argvars, typval_T *rettv)
}
/*
- * "jsonencode()" function
+ * "json_encode()" function
*/
static void
-f_jsonencode(typval_T *argvars, typval_T *rettv)
+f_json_encode(typval_T *argvars, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = json_encode(&argvars[0], 0);
diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim
index 2534de1..3ac936f 100644
--- a/src/testdir/test_json.vim
+++ b/src/testdir/test_json.vim
@@ -55,199 +55,199 @@ let s:jsonvals = '[true,false,null,null]'
let s:varvals = [v:true, v:false, v:null, v:null]
func Test_json_encode()
- call assert_equal(s:json1, jsonencode(s:var1))
- call assert_equal(s:json2, jsonencode(s:var2))
- call assert_equal(s:json3, jsonencode(s:var3))
- call assert_equal(s:json4, jsonencode(s:var4))
- call assert_equal(s:json5, jsonencode(s:var5))
+ call assert_equal(s:json1, json_encode(s:var1))
+ call assert_equal(s:json2, json_encode(s:var2))
+ call assert_equal(s:json3, json_encode(s:var3))
+ call assert_equal(s:json4, json_encode(s:var4))
+ call assert_equal(s:json5, json_encode(s:var5))
if has('multi_byte')
- call assert_equal(s:jsonmb, jsonencode(s:varmb))
+ call assert_equal(s:jsonmb, json_encode(s:varmb))
endif
- call assert_equal(s:jsonnr, jsonencode(s:varnr))
+ call assert_equal(s:jsonnr, json_encode(s:varnr))
if has('float')
- call assert_equal(s:jsonfl, jsonencode(s:varfl))
+ call assert_equal(s:jsonfl, json_encode(s:varfl))
endif
- call assert_equal(s:jsonl1, jsonencode(s:varl1))
- call assert_equal(s:jsonl2, jsonencode(s:varl2))
- call assert_equal(s:jsonl3, jsonencode(s:varl3))
+ call assert_equal(s:jsonl1, json_encode(s:varl1))
+ call assert_equal(s:jsonl2, json_encode(s:varl2))
+ call assert_equal(s:jsonl3, json_encode(s:varl3))
- call assert_equal(s:jsond1, jsonencode(s:vard1))
- call assert_equal(s:jsond2, jsonencode(s:vard2))
- call assert_equal(s:jsond3, jsonencode(s:vard3))
- call assert_equal(s:jsond4, jsonencode(s:vard4))
+ call assert_equal(s:jsond1, json_encode(s:vard1))
+ call assert_equal(s:jsond2, json_encode(s:vard2))
+ call assert_equal(s:jsond3, json_encode(s:vard3))
+ call assert_equal(s:jsond4, json_encode(s:vard4))
- call assert_equal(s:jsonvals, jsonencode(s:varvals))
+ call assert_equal(s:jsonvals, json_encode(s:varvals))
- call assert_fails('echo jsonencode(function("tr"))', 'E474:')
- call assert_fails('echo jsonencode([function("tr")])', 'E474:')
+ call assert_fails('echo json_encode(function("tr"))', 'E474:')
+ call assert_fails('echo json_encode([function("tr")])', 'E474:')
- silent! let res = jsonencode(function("tr"))
+ silent! let res = json_encode(function("tr"))
call assert_equal("", res)
endfunc
func Test_json_decode()
- call assert_equal(s:var1, jsondecode(s:json1))
- call assert_equal(s:var2, jsondecode(s:json2))
- call assert_equal(s:var3, jsondecode(s:json3))
- call assert_equal(s:var4, jsondecode(s:json4))
- call assert_equal(s:var5, jsondecode(s:json5))
+ call assert_equal(s:var1, json_decode(s:json1))
+ call assert_equal(s:var2, json_decode(s:json2))
+ call assert_equal(s:var3, json_decode(s:json3))
+ call assert_equal(s:var4, json_decode(s:json4))
+ call assert_equal(s:var5, json_decode(s:json5))
if has('multi_byte')
- call assert_equal(s:varmb, jsondecode(s:jsonmb))
+ call assert_equal(s:varmb, json_decode(s:jsonmb))
endif
- call assert_equal(s:varnr, jsondecode(s:jsonnr))
+ call assert_equal(s:varnr, json_decode(s:jsonnr))
if has('float')
- call assert_equal(s:varfl, jsondecode(s:jsonfl))
+ call assert_equal(s:varfl, json_decode(s:jsonfl))
endif
- call assert_equal(s:varl1, jsondecode(s:jsonl1))
- call assert_equal(s:varl2x, jsondecode(s:jsonl2))
- call assert_equal(s:varl2x, jsondecode(s:jsonl2s))
- call assert_equal(s:varl3, jsondecode(s:jsonl3))
-
- call assert_equal(s:vard1, jsondecode(s:jsond1))
- call assert_equal(s:vard2x, jsondecode(s:jsond2))
- call assert_equal(s:vard2x, jsondecode(s:jsond2s))
- call assert_equal(s:vard3, jsondecode(s:jsond3))
- call assert_equal(s:vard4x, jsondecode(s:jsond4))
-
- call assert_equal(s:varvals, jsondecode(s:jsonvals))
-
- call assert_equal(v:true, jsondecode('true'))
- call assert_equal(type(v:true), type(jsondecode('true')))
- call assert_equal(v:none, jsondecode(''))
- call assert_equal(type(v:none), type(jsondecode('')))
- call assert_equal("", jsondecode('""'))
-
- call assert_equal({'n': 1}, jsondecode('{"n":1,}'))
-
- call assert_fails('call jsondecode("\"")', "E474:")
- call assert_fails('call jsondecode("blah")', "E474:")
- call assert_fails('call jsondecode("true blah")', "E474:")
- call assert_fails('call jsondecode("<foobar>")', "E474:")
-
- call assert_fails('call jsondecode("{")', "E474:")
- call assert_fails('call jsondecode("{foobar}")', "E474:")
- call assert_fails('call jsondecode("{\"n\",")', "E474:")
- call assert_fails('call jsondecode("{\"n\":")', "E474:")
- call assert_fails('call jsondecode("{\"n\":1")', "E474:")
- call assert_fails('call jsondecode("{\"n\":1,")', "E474:")
- call assert_fails('call jsondecode("{\"n\",1}")', "E474:")
- call assert_fails('call jsondecode("{-}")', "E474:")
-
- call assert_fails('call jsondecode("[foobar]")', "E474:")
- call assert_fails('call jsondecode("[")', "E474:")
- call assert_fails('call jsondecode("[1")', "E474:")
- call assert_fails('call jsondecode("[1,")', "E474:")
- call assert_fails('call jsondecode("[1 2]")', "E474:")
-
- call assert_fails('call jsondecode("[1,,2]")', "E474:")
+ call assert_equal(s:varl1, json_decode(s:jsonl1))
+ call assert_equal(s:varl2x, json_decode(s:jsonl2))
+ call assert_equal(s:varl2x, json_decode(s:jsonl2s))
+ call assert_equal(s:varl3, json_decode(s:jsonl3))
+
+ call assert_equal(s:vard1, json_decode(s:jsond1))
+ call assert_equal(s:vard2x, json_decode(s:jsond2))
+ call assert_equal(s:vard2x, json_decode(s:jsond2s))
+ call assert_equal(s:vard3, json_decode(s:jsond3))
+ call assert_equal(s:vard4x, json_decode(s:jsond4))
+
+ call assert_equal(s:varvals, json_decode(s:jsonvals))
+
+ call assert_equal(v:true, json_decode('true'))
+ call assert_equal(type(v:true), type(json_decode('true')))
+ call assert_equal(v:none, json_decode(''))
+ call assert_equal(type(v:none), type(json_decode('')))
+ call assert_equal("", json_decode('""'))
+
+ call assert_equal({'n': 1}, json_decode('{"n":1,}'))
+
+ call assert_fails('call json_decode("\"")', "E474:")
+ call assert_fails('call json_decode("blah")', "E474:")
+ call assert_fails('call json_decode("true blah")', "E474:")
+ call assert_fails('call json_decode("<foobar>")', "E474:")
+
+ call assert_fails('call json_decode("{")', "E474:")
+ call assert_fails('call json_decode("{foobar}")', "E474:")
+ call assert_fails('call json_decode("{\"n\",")', "E474:")
+ call assert_fails('call json_decode("{\"n\":")', "E474:")
+ call assert_fails('call json_decode("{\"n\":1")', "E474:")
+ call assert_fails('call json_decode("{\"n\":1,")', "E474:")
+ call assert_fails('call json_decode("{\"n\",1}")', "E474:")
+ call assert_fails('call json_decode("{-}")', "E474:")
+
+ call assert_fails('call json_decode("[foobar]")', "E474:")
+ call assert_fails('call json_decode("[")', "E474:")
+ call assert_fails('call json_decode("[1")', "E474:")
+ call assert_fails('call json_decode("[1,")', "E474:")
+ call assert_fails('call json_decode("[1 2]")', "E474:")
+
+ call assert_fails('call json_decode("[1,,2]")', "E474:")
endfunc
let s:jsl5 = '[7,,,]'
let s:varl5 = [7, v:none, v:none]
func Test_js_encode()
- call assert_equal(s:json1, jsencode(s:var1))
- call assert_equal(s:json2, jsencode(s:var2))
- call assert_equal(s:json3, jsencode(s:var3))
- call assert_equal(s:json4, jsencode(s:var4))
- call assert_equal(s:json5, jsencode(s:var5))
+ call assert_equal(s:json1, js_encode(s:var1))
+ call assert_equal(s:json2, js_encode(s:var2))
+ call assert_equal(s:json3, js_encode(s:var3))
+ call assert_equal(s:json4, js_encode(s:var4))
+ call assert_equal(s:json5, js_encode(s:var5))
if has('multi_byte')
- call assert_equal(s:jsonmb, jsencode(s:varmb))
+ call assert_equal(s:jsonmb, js_encode(s:varmb))
endif
- call assert_equal(s:jsonnr, jsencode(s:varnr))
+ call assert_equal(s:jsonnr, js_encode(s:varnr))
if has('float')
- call assert_equal(s:jsonfl, jsencode(s:varfl))
+ call assert_equal(s:jsonfl, js_encode(s:varfl))
endif
- call assert_equal(s:jsonl1, jsencode(s:varl1))
- call assert_equal(s:jsonl2, jsencode(s:varl2))
- call assert_equal(s:jsonl3, jsencode(s:varl3))
+ call assert_equal(s:jsonl1, js_encode(s:varl1))
+ call assert_equal(s:jsonl2, js_encode(s:varl2))
+ call assert_equal(s:jsonl3, js_encode(s:varl3))
- call assert_equal(s:jsd1, jsencode(s:vard1))
- call assert_equal(s:jsd2, jsencode(s:vard2))
- call assert_equal(s:jsd3, jsencode(s:vard3))
- call assert_equal(s:jsd4, jsencode(s:vard4))
+ call assert_equal(s:jsd1, js_encode(s:vard1))
+ call assert_equal(s:jsd2, js_encode(s:vard2))
+ call assert_equal(s:jsd3, js_encode(s:vard3))
+ call assert_equal(s:jsd4, js_encode(s:vard4))
- call assert_equal(s:jsonvals, jsencode(s:varvals))
+ call assert_equal(s:jsonvals, js_encode(s:varvals))
- call assert_fails('echo jsencode(function("tr"))', 'E474:')
- call assert_fails('echo jsencode([function("tr")])', 'E474:')
+ call assert_fails('echo js_encode(function("tr"))', 'E474:')
+ call assert_fails('echo js_encode([function("tr")])', 'E474:')
- silent! let res = jsencode(function("tr"))
+ silent! let res = js_encode(function("tr"))
call assert_equal("", res)
- call assert_equal(s:jsl5, jsencode(s:varl5))
+ call assert_equal(s:jsl5, js_encode(s:varl5))
endfunc
func Test_js_decode()
- call assert_equal(s:var1, jsdecode(s:json1))
- call assert_equal(s:var2, jsdecode(s:json2))
- call assert_equal(s:var3, jsdecode(s:json3))
- call assert_equal(s:var4, jsdecode(s:json4))
- call assert_equal(s:var5, jsdecode(s:json5))
+ call assert_equal(s:var1, js_decode(s:json1))
+ call assert_equal(s:var2, js_decode(s:json2))
+ call assert_equal(s:var3, js_decode(s:json3))
+ call assert_equal(s:var4, js_decode(s:json4))
+ call assert_equal(s:var5, js_decode(s:json5))
if has('multi_byte')
- call assert_equal(s:varmb, jsdecode(s:jsonmb))
+ call assert_equal(s:varmb, js_decode(s:jsonmb))
endif
- call assert_equal(s:varnr, jsdecode(s:jsonnr))
+ call assert_equal(s:varnr, js_decode(s:jsonnr))
if has('float')
- call assert_equal(s:varfl, jsdecode(s:jsonfl))
+ call assert_equal(s:varfl, js_decode(s:jsonfl))
endif
- call assert_equal(s:varl1, jsdecode(s:jsonl1))
- call assert_equal(s:varl2x, jsdecode(s:jsonl2))
- call assert_equal(s:varl2x, jsdecode(s:jsonl2s))
- call assert_equal(s:varl3, jsdecode(s:jsonl3))
-
- call assert_equal(s:vard1, jsdecode(s:jsond1))
- call assert_equal(s:vard1, jsdecode(s:jsd1))
- call assert_equal(s:vard2x, jsdecode(s:jsond2))
- call assert_equal(s:vard2x, jsdecode(s:jsd2))
- call assert_equal(s:vard2x, jsdecode(s:jsond2s))
- call assert_equal(s:vard2x, jsdecode(s:jsd2s))
- call assert_equal(s:vard3, jsdecode(s:jsond3))
- call assert_equal(s:vard3, jsdecode(s:jsd3))
- call assert_equal(s:vard4x, jsdecode(s:jsond4))
- call assert_equal(s:vard4x, jsdecode(s:jsd4))
-
- call assert_equal(s:varvals, jsdecode(s:jsonvals))
-
- call assert_equal(v:true, jsdecode('true'))
- call assert_equal(type(v:true), type(jsdecode('true')))
- call assert_equal(v:none, jsdecode(''))
- call assert_equal(type(v:none), type(jsdecode('')))
- call assert_equal("", jsdecode('""'))
-
- call assert_equal({'n': 1}, jsdecode('{"n":1,}'))
-
- call assert_fails('call jsdecode("\"")', "E474:")
- call assert_fails('call jsdecode("blah")', "E474:")
- call assert_fails('call jsdecode("true blah")', "E474:")
- call assert_fails('call jsdecode("<foobar>")', "E474:")
-
- call assert_fails('call jsdecode("{")', "E474:")
- call assert_fails('call jsdecode("{foobar}")', "E474:")
- call assert_fails('call jsdecode("{\"n\",")', "E474:")
- call assert_fails('call jsdecode("{\"n\":")', "E474:")
- call assert_fails('call jsdecode("{\"n\":1")', "E474:")
- call assert_fails('call jsdecode("{\"n\":1,")', "E474:")
- call assert_fails('call jsdecode("{\"n\",1}")', "E474:")
- call assert_fails('call jsdecode("{-}")', "E474:")
-
- call assert_fails('call jsdecode("[foobar]")', "E474:")
- call assert_fails('call jsdecode("[")', "E474:")
- call assert_fails('call jsdecode("[1")', "E474:")
- call assert_fails('call jsdecode("[1,")', "E474:")
- call assert_fails('call jsdecode("[1 2]")', "E474:")
-
- call assert_equal(s:varl5, jsdecode(s:jsl5))
+ call assert_equal(s:varl1, js_decode(s:jsonl1))
+ call assert_equal(s:varl2x, js_decode(s:jsonl2))
+ call assert_equal(s:varl2x, js_decode(s:jsonl2s))
+ call assert_equal(s:varl3, js_decode(s:jsonl3))
+
+ call assert_equal(s:vard1, js_decode(s:jsond1))
+ call assert_equal(s:vard1, js_decode(s:jsd1))
+ call assert_equal(s:vard2x, js_decode(s:jsond2))
+ call assert_equal(s:vard2x, js_decode(s:jsd2))
+ call assert_equal(s:vard2x, js_decode(s:jsond2s))
+ call assert_equal(s:vard2x, js_decode(s:jsd2s))
+ call assert_equal(s:vard3, js_decode(s:jsond3))
+ call assert_equal(s:vard3, js_decode(s:jsd3))
+ call assert_equal(s:vard4x, js_decode(s:jsond4))
+ call assert_equal(s:vard4x, js_decode(s:jsd4))
+
+ call assert_equal(s:varvals, js_decode(s:jsonvals))
+
+ call assert_equal(v:true, js_decode('true'))
+ call assert_equal(type(v:true), type(js_decode('true')))
+ call assert_equal(v:none, js_decode(''))
+ call assert_equal(type(v:none), type(js_decode('')))
+ call assert_equal("", js_decode('""'))
+
+ call assert_equal({'n': 1}, js_decode('{"n":1,}'))
+
+ call assert_fails('call js_decode("\"")', "E474:")
+ call assert_fails('call js_decode("blah")', "E474:")
+ call assert_fails('call js_decode("true blah")', "E474:")
+ call assert_fails('call js_decode("<foobar>")', "E474:")
+
+ call assert_fails('call js_decode("{")', "E474:")
+ call assert_fails('call js_decode("{foobar}")', "E474:")
+ call assert_fails('call js_decode("{\"n\",")', "E474:")
+ call assert_fails('call js_decode("{\"n\":")', "E474:")
+ call assert_fails('call js_decode("{\"n\":1")', "E474:")
+ call assert_fails('call js_decode("{\"n\":1,")', "E474:")
+ call assert_fails('call js_decode("{\"n\",1}")', "E474:")
+ call assert_fails('call js_decode("{-}")', "E474:")
+
+ call assert_fails('call js_decode("[foobar]")', "E474:")
+ call assert_fails('call js_decode("[")', "E474:")
+ call assert_fails('call js_decode("[1")', "E474:")
+ call assert_fails('call js_decode("[1,")', "E474:")
+ call assert_fails('call js_decode("[1 2]")', "E474:")
+
+ call assert_equal(s:varl5, js_decode(s:jsl5))
endfunc