Permalink
Browse files

patch 7.4.1154

Problem:    No support for JSON.
Solution:   Add jsonencode() and jsondecode().  Also add v:false, v:true,
            v:null and v:none.
  • Loading branch information...
brammool committed Jan 23, 2016
1 parent 6920c72 commit 520e1e41f35b063ede63b41738c82d6636e78c34
View
@@ -40,6 +40,7 @@ SRC_ALL = \
src/hardcopy.c \
src/hashtab.c \
src/keymap.h \
src/json.c \
src/macros.h \
src/main.c \
src/mark.c \
@@ -132,6 +133,7 @@ SRC_ALL = \
src/proto/gui_beval.pro \
src/proto/hardcopy.pro \
src/proto/hashtab.pro \
src/proto/json.pro \
src/proto/main.pro \
src/proto/mark.pro \
src/proto/mbyte.pro \
View
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.4. Last change: 2016 Jan 21
*eval.txt* For Vim version 7.4. Last change: 2016 Jan 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1409,6 +1409,10 @@ v:exception The value of the exception most recently caught and not
:endtry
< Output: "caught oops".
*v:false* *false-variable*
v:false A Number with value zero. Used to put "false" in JSON. See
|jsonencode()|.
*v:fcs_reason* *fcs_reason-variable*
v:fcs_reason The reason why the |FileChangedShell| event was triggered.
Can be used in an autocommand to decide what to do and/or what
@@ -1542,6 +1546,14 @@ v:mouse_col Column number for a mouse click obtained with |getchar()|.
This is the screen column number, like with |virtcol()|. The
value is zero when there was no mouse button click.
*v:none* *none-variable*
v:none An empty String. Used to put an empty item in JSON. See
|jsonencode()|.
*v:null* *null-variable*
v:null An empty String. Used to put "null" in JSON. See
|jsonencode()|.
*v:oldfiles* *oldfiles-variable*
v:oldfiles List of file names that is loaded from the |viminfo| file on
startup. These are the files that Vim remembers marks for.
@@ -1707,6 +1719,10 @@ v:throwpoint The point where the exception most recently caught and not
:endtry
< Output: "Exception from test.vim, line 2"
*v:true* *true-variable*
v:true A Number with value one. Used to put "true" in JSON. See
|jsonencode()|.
*v:val* *val-variable*
v:val Value of the current item of a |List| or |Dictionary|. Only
valid while evaluating the expression used with |map()| and
@@ -1913,6 +1929,8 @@ isdirectory( {directory}) Number TRUE if {directory} is a directory
islocked( {expr}) Number TRUE if {expr} is locked
items( {dict}) List key-value pairs in {dict}
join( {list} [, {sep}]) String join {list} items into one String
jsondecode( {string}) any decode JSON
jsonencode( {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}
@@ -4215,6 +4233,27 @@ join({list} [, {sep}]) *join()*
converted into a string like with |string()|.
The opposite function is |split()|.
jsondecode({string}) *jsondecode()*
TODO
jsonencode({expr}) *jsonencode()*
Encodode {expr} as JSON and return this as a string.
The encoding is specified in:
http://www.ietf.org/rfc/rfc4627.txt
Vim values are converted as follows:
Number decimal number
Float floating point number
String in double quotes (possibly null)
Funcref nothing
List as an array (possibly null); when
used recursively: []
Dict as an object (possibly null); when
used recursively: {}
v:false "false"
v:true "true"
v:none nothing
v:null "null"
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order.
View
@@ -72,6 +72,7 @@ EXE_dependencies = \
getchar.obj \
hardcopy.obj \
hashtab.obj \
json.obj \
main.obj \
mark.obj \
memfile.obj \
View
@@ -598,6 +598,7 @@ vimobj = \
$(OBJDIR)\getchar.obj \
$(OBJDIR)\hardcopy.obj \
$(OBJDIR)\hashtab.obj \
$(OBJDIR)\json.obj \
$(OBJDIR)\main.obj \
$(OBJDIR)\mark.obj \
$(OBJDIR)\memfile.obj \
View
@@ -601,6 +601,7 @@ OBJ = \
$(OUTDIR)/getchar.o \
$(OUTDIR)/hardcopy.o \
$(OUTDIR)/hashtab.o \
$(OUTDIR)/json.o \
$(OUTDIR)/main.o \
$(OUTDIR)/mark.o \
$(OUTDIR)/memfile.o \
View
@@ -45,6 +45,7 @@ SRC = \
getchar.c \
hardcopy.c \
hashtab.c \
json.c \
main.c \
mark.c \
memfile.c \
@@ -93,6 +94,7 @@ OBJ = o/blowfish.o \
o/getchar.o \
o/hardcopy.o \
o/hashtab.o \
o/json.o \
o/main.o \
o/mark.o \
o/memfile.o \
@@ -179,6 +181,8 @@ o/hardcopy.o: hardcopy.c $(SYMS)
o/hashtab.o: hashtab.c $(SYMS)
o/json.o: json.c $(SYMS)
o/main.o: main.c $(SYMS)
o/mark.o: mark.c $(SYMS)
View
@@ -229,6 +229,7 @@ LINK32_OBJS= \
"$(INTDIR)/getchar.obj" \
"$(INTDIR)/hardcopy.obj" \
"$(INTDIR)/hashtab.obj" \
"$(INTDIR)/json.obj" \
"$(INTDIR)/main.obj" \
"$(INTDIR)/mark.obj" \
"$(INTDIR)/mbyte.obj" \
@@ -555,6 +556,10 @@ SOURCE=.\if_ole.idl
# End Source File
# Begin Source File
SOURCE=.\json.c
# End Source File
# Begin Source File
SOURCE=.\main.c
# End Source File
# Begin Source File
View
@@ -55,6 +55,7 @@ SRC = blowfish.c \
getchar.c \
hardcopy.c \
hashtab.c \
json.c \
main.c \
mark.c \
memfile.c \
@@ -105,6 +106,7 @@ OBJ = obj/blowfish.o \
obj/getchar.o \
obj/hardcopy.o \
obj/hashtab.o \
obj/json.o \
obj/main.o \
obj/mark.o \
obj/memfile.o \
@@ -153,6 +155,7 @@ PRO = proto/blowfish.pro \
proto/getchar.pro \
proto/hardcopy.pro \
proto/hashtab.pro \
proto/json.pro \
proto/main.pro \
proto/mark.pro \
proto/memfile.pro \
@@ -284,6 +287,9 @@ obj/hardcopy.o: hardcopy.c
obj/hashtab.o: hashtab.c
$(CCSYM) $@ hashtab.c
obj/json.o: json.c
$(CCSYM) $@ json.c
# Don't use $(SYMS) here, because main.c defines EXTERN
obj/main.o: main.c option.h globals.h
$(CCNOSYM) $@ main.c
View
@@ -43,6 +43,7 @@ SRC = blowfish.c \
getchar.c \
hardcopy.c \
hashtab.c \
json.c \
main.c \
mark.c \
mbyte.c \
View
@@ -536,6 +536,7 @@ OBJ = \
$(OUTDIR)\getchar.obj \
$(OUTDIR)\hardcopy.obj \
$(OUTDIR)\hashtab.obj \
$(OUTDIR)\json.obj \
$(OUTDIR)\main.obj \
$(OUTDIR)\mark.obj \
$(OUTDIR)\mbyte.obj \
@@ -1202,6 +1203,8 @@ $(OUTDIR)/if_sniff.obj: $(OUTDIR) if_sniff.c $(INCL)
$(OUTDIR)/if_tcl.obj: $(OUTDIR) if_tcl.c $(INCL)
$(CC) $(CFLAGS) $(TCL_INC) if_tcl.c
$(OUTDIR)/json.obj: $(OUTDIR) json.c $(INCL)
$(OUTDIR)/main.obj: $(OUTDIR) main.c $(INCL)
$(OUTDIR)/mark.obj: $(OUTDIR) mark.c $(INCL)
@@ -1329,6 +1332,7 @@ proto.h: \
proto/getchar.pro \
proto/hardcopy.pro \
proto/hashtab.pro \
proto/json.pro \
proto/main.pro \
proto/mark.pro \
proto/memfile.pro \
View
@@ -108,6 +108,7 @@ SRC = \
getchar.c \
hardcopy.c \
hashtab.c \
json.c \
main.c \
mark.c \
memfile.c \
@@ -157,6 +158,7 @@ OBJ = \
getchar.o \
hardcopy.o \
hashtab.o \
json.o \
main.o \
mark.o \
memfile.o \
@@ -206,6 +208,7 @@ PRO = \
proto/getchar.pro \
proto/hardcopy.pro \
proto/hashtab.pro \
proto/json.pro \
proto/main.pro \
proto/mark.pro \
proto/memfile.pro \
@@ -328,6 +331,8 @@ hardcopy.o: hardcopy.c
proto/hardcopy.pro: hardcopy.c
hashtab.o: hashtab.c
proto/hashtab.pro: hashtab.c
json.o: json.c
proto/json.pro: json.c
main.o: main.c
proto/main.pro: main.c
mark.o: mark.c
View
@@ -2,7 +2,7 @@
# Makefile for Vim on OpenVMS
#
# Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com>
# Last change: 2014 Aug 10
# Last change: 2016 Jan 22
#
# This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
# with MMS and MMK
@@ -311,7 +311,7 @@ ALL_LIBS = $(LIBS) $(GUI_LIB_DIR) $(GUI_LIB) \
SRC = blowfish.c buffer.c charset.c crypt.c, crypt_zip.c diff.c digraph.c edit.c eval.c ex_cmds.c ex_cmds2.c \
ex_docmd.c ex_eval.c ex_getln.c if_xcmdsrv.c fileio.c fold.c getchar.c \
hardcopy.c hashtab.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
hardcopy.c hashtab.c json.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
misc2.c move.c normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c sha256.c\
spell.c syntax.c tag.c term.c termlib.c ui.c undo.c version.c screen.c \
window.c os_unix.c os_vms.c pathdef.c \
@@ -320,7 +320,7 @@ SRC = blowfish.c buffer.c charset.c crypt.c, crypt_zip.c diff.c digraph.c edit.c
OBJ = blowfish.obj buffer.obj charset.obj crypt.obj, crypt_zip.obj diff.obj digraph.obj edit.obj eval.obj \
ex_cmds.obj ex_cmds2.obj ex_docmd.obj ex_eval.obj ex_getln.obj \
if_xcmdsrv.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtab.obj main.obj mark.obj \
if_xcmdsrv.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtab.obj json.obj main.obj mark.obj \
menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \
move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj quickfix.obj \
regexp.obj search.obj sha256.obj spell.obj syntax.obj tag.obj term.obj termlib.obj \
@@ -572,6 +572,10 @@ if_mzsch.obj : if_mzsch.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h [.proto]gui_beval.pro ex_cmds.h proto.h \
globals.h farsi.h arabic.h if_mzsch.h
json.obj : json.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
arabic.h version.h
main.obj : main.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
Oops, something went wrong.

0 comments on commit 520e1e4

Please sign in to comment.