patch 8.1.1158: json encoded string is sometimes missing the final NUL

Problem:    Json encoded string is sometimes missing the final NUL.
Solution:   Add the NUL.  Also for log messages.
diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim
index fb3d992..e16a7f0 100644
--- a/src/testdir/test_json.vim
+++ b/src/testdir/test_json.vim
@@ -289,3 +289,10 @@
 
   call assert_equal(s:varl5, js_decode(s:jsl5))
 endfunc
+
+func Test_json_encode_long()
+  " The growarray uses a grow size of 4000, check that a result that is exactly
+  " 4000 bytes long is not missing the final NUL.
+  let json = json_encode([repeat('a', 3996)])
+  call assert_equal(4000, len(json))
+endfunc