patch 7.4.1279
Problem:    jsonencode() is not producing strict JSON.
Solution:   Add jsencode() and jsdecode().  Make jsonencode() and jsondecode()
            strict.
diff --git a/src/channel.c b/src/channel.c
index a6458c6..1d12ee7 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -119,7 +119,7 @@
     char_u    *ch_callback;	/* function to call when a msg is not handled */
     cbq_T     ch_cb_head;	/* dummy node for pre-request callbacks */
 
-    int	      ch_json_mode;	/* TRUE for a json channel */
+    ch_mode_T ch_mode;
     jsonq_T   ch_json_head;	/* dummy node, header for circular queue */
 
     int       ch_timeout;	/* request timeout in msec */
@@ -526,12 +526,12 @@
 }
 
 /*
- * Set the json mode of channel "idx" to TRUE or FALSE.
+ * Set the json mode of channel "idx" to "ch_mode".
  */
     void
-channel_set_json_mode(int idx, int json_mode)
+channel_set_json_mode(int idx, ch_mode_T ch_mode)
 {
-    channels[idx].ch_json_mode = json_mode;
+    channels[idx].ch_mode = ch_mode;
 }
 
 /*
@@ -672,7 +672,8 @@
     js_read_T	reader;
     typval_T	listtv;
     jsonq_T	*item;
-    jsonq_T	*head = &channels[ch_idx].ch_json_head;
+    channel_T	*channel = &channels[ch_idx];
+    jsonq_T	*head = &channel->ch_json_head;
     int		ret;
 
     if (channel_peek(ch_idx) == NULL)
@@ -685,7 +686,8 @@
     reader.js_fill = NULL;
     /* reader.js_fill = channel_fill; */
     reader.js_cookie = &ch_idx;
-    ret = json_decode(&reader, &listtv);
+    ret = json_decode(&reader, &listtv,
+				   channel->ch_mode == MODE_JS ? JSON_JS : 0);
     if (ret == OK)
     {
 	/* Only accept the response when it is a list with at least two
@@ -854,6 +856,8 @@
 	    typval_T	*tv;
 	    typval_T	err_tv;
 	    char_u	*json = NULL;
+	    channel_T	*channel = &channels[idx];
+	    int		options = channel->ch_mode == MODE_JS ? JSON_JS : 0;
 
 	    /* Don't pollute the display with errors. */
 	    ++emsg_skip;
@@ -861,7 +865,8 @@
 	    if (is_eval)
 	    {
 		if (tv != NULL)
-		    json = json_encode_nr_expr(arg3->vval.v_number, tv);
+		    json = json_encode_nr_expr(arg3->vval.v_number, tv,
+								     options);
 		if (tv == NULL || (json != NULL && *json == NUL))
 		{
 		    /* If evaluation failed or the result can't be encoded
@@ -869,7 +874,8 @@
 		    err_tv.v_type = VAR_STRING;
 		    err_tv.vval.v_string = (char_u *)"ERROR";
 		    tv = &err_tv;
-		    json = json_encode_nr_expr(arg3->vval.v_number, tv);
+		    json = json_encode_nr_expr(arg3->vval.v_number, tv,
+								     options);
 		}
 		if (json != NULL)
 		{
@@ -900,13 +906,13 @@
     typval_T	argv[3];
     int		seq_nr = -1;
     channel_T	*channel = &channels[idx];
-    int		json_mode = channel->ch_json_mode;
+    ch_mode_T	ch_mode = channel->ch_mode;
 
     if (channel->ch_close_cb != NULL)
 	/* this channel is handled elsewhere (netbeans) */
 	return FALSE;
 
-    if (json_mode)
+    if (ch_mode != MODE_RAW)
     {
 	/* Get any json message in the queue. */
 	if (channel_get_json(idx, -1, &listtv) == FAIL)