GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kscript/json-pack: 一个用于将json数据压缩/解压的npm模块 查看示例页面 https://kscript.github.io/json-pack/demo

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
demo
demo
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

@kscript/json-pack

A simple JSON packer/unpacker

example

const jsonPack = require('@kscript/json-pack');
const user = {
  a: 1,
  aa: 11,
  aaa: 111,
  aaaa: {
    b: 2,
    bb: 22,
    bbb: 222,
    bbbb: {
      a: 3,
      aa: 33,
      aa: 333
    }
  },
  d: [
    {
      a: 1,
      d: 4
    },
    {
      aa: 11,
      dd: 44
    },
    {
      aaa: 111,
      ddd: 444
    },
    {
      aaaa: 1111,
      dddd: 4444
    },
    {
      aaaa: 1111,
      dddd: 4444
    },
    {
      aaaa: 1111,
      dddd: 4444
    }
  ]
}
// keys的引用不会丢失, 可以是一个公共的key数组, 用于多文件压缩
// 单文件压缩时, keys会一起压缩, 每个文件都可以直接解压
// 多文件压缩时, keys是公共的, 动态增加的, 需要自行保存好
const options = { keys: [] }
console.log([
  // 压缩
  jsonPack.compress(user),
  // 压缩 + 解压
  // 压缩时不传keys数组, 返回压缩后的content
  // 传入keys数组, 返回的是[content, options]数组(与解压函数的参数一一对应)
  jsonPack.decompress(...jsonPack.compress(user, options))
])

About

一个用于将json数据压缩/解压的npm模块 查看示例页面 https://kscript.github.io/json-pack/demo

kscript.github.io/json-pack/demo

Topics

jsonjson-packnpmpack

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.