Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.json_encode

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.json_encode
import { fn } from "https://deno.land/x/ddc_vim@v4.0.2/deps.ts";
const { json_encode } = fn;

Encode {expr} as JSON and return this as a string. The encoding is specified in: https://tools.ietf.org/html/rfc7159.html Vim values are converted as follows: Number decimal number Float floating point number Float nan "NaN" Float inf "Infinity" Float -inf "-Infinity" String in double quotes (possibly null) Funcref not possible, error List as an array (possibly null); when used recursively: [] Dict as an object (possibly null); when used recursively: {} Blob as an array of the individual bytes v:false "false" v:true "true" v:none "null" v:null "null" Note that NaN and Infinity are passed on as values. This is missing in the JSON standard, but several implementations do allow it. If not then you will get an error. If a string contains an illegal character then the replacement character 0xfffd is used.

Can also be used as a method:

GetObject()->json_encode()

Parameters

denops: Denops
expr: unknown

Returns

Promise<string>