Skip to content

Add support for marshalling JSON #383

Description

@GoogleCodeExporter
Could vim have a built-in tojson({value}) and fromjson({json}) helpers to 
serialize and deserialize JSON?

JSON is used in lots of vim plugins like 
https://github.com/Valloric/YouCompleteMe, 
https://github.com/google/vim-maktaba, 
https://github.com/MarcWeber/vim-addon-manager, and eventually Vundle 
(https://github.com/VundleVim/Vundle.vim/pull/560). These can either use slow 
hacks or depend on python support, but it would be best if vim just had native, 
performant support for JSON marshalling built in.

Expected behavior
  :echo tojson({'a': [1, 'foo'], 'b': 2.1}) ==# '{"a": [1, "foo"], "b": 2.1}'
  1
  :echo fromjson("[1.0, {}, []]") ==# [1.0, {}, []]
  1
  :echo tojson(fromjson('[null, true, false]')) ==# '[null, true, false]'
  1

Note in the last example there needs to be a way to represent null, true, and 
false unambiguously even though vim doesn't have these primitives. Also, 
fromjson() could use an option to translate into standard vim equivalents like 
'', 1, and 0.

Original issue reported on code.google.com by daviebd...@gmail.com on 13 Jul 2015 at 11:30

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions