Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denops_std/function/vim/mod.ts>js_encode

📚 Standard module for denops.vim
Go to Latest
function js_encode
import { js_encode } from "https://deno.land/x/denops_std@v3.8.1/function/vim/mod.ts";

This is similar to |json_encode()| with these differences:

  • Object key names are not in quotes.
  • v:none items in an array result in an empty item between commas. For example, the Vim object: [1,v:none,{"one":1},v:none] ~ Will be encoded as: [1,,{one:1},,] ~ While json_encode() would produce: [1,null,{"one":1},null] ~ This encoding is valid for JavaScript. It is more efficient than JSON, especially when using an array with optional items. Can also be used as a |method|: GetObject()->js_encode()

Parameters

denops: Denops
expr: unknown

Returns

Promise<unknown>