LoginSignup
1

More than 5 years have passed since last update.

webapi.vim の、webapi#json#encode での真偽値の扱い

Last updated at Posted at 2013-05-28

Vimscrpit にはBoolean型がないが、JSONではBooleanを扱えるのでその変換をどうするか。

webapi#json#encode に渡す辞書に、webapi#json 内でnull, true, falseを扱うための関数の参照を突っ込んでおくと、適宜null, true, falseに置き換えられたJSON文字列を生成してくれる。


:let json = webapi#json#encode({'flag':function('webapi#json#true')})
:echo json #=> {"flag":true}

webapi.vim のjson.vimを読めば分かるけど、備忘録として。

[2013-05-28 23:55]

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1