Code Monkey home page Code Monkey logo

format-json-utils's Introduction

format-json-utils

npm version license npm bundle size

format-json-utils 是一个用于在JavaScript中格式化JSON字符串的工具,它基于ES Modules (ESM) 语法实现。支持 Vue2、Vue3、React。。。

安装

使用npm安装:

npm install format-json-utils

使用yarn安装:

yarn add format-json-utils

使用示例 以下是一个简单的示例,演示如何在 JavaScript 项目中使用 format-json-utils 来格式化 JSON 数据:

import { formatJSON } from 'format-json-utils';

// 场景一
const jsonData = {name: 'John Doe',age: 30,email: '[email protected]'}; 
// 场景二
// const jsonData = "{\"name\": \"John Doe\", \"age\": \"30\",\"email\": \'[email protected]\'}"; 

const formattedJSON = formatJSON(jsonData);
console.log(formattedJSON);
//{
//    "name":"John Doe",
//    "age":"30",
//    "email":"[email protected]"
//}

API 文档

formatJSON(jsonObj, errorCallBack): string

此函数接受一个 JSON 数据对象和一个可选的 error 回调函数,返回格式化后的 JSON 字符串。

许可证

本项目基于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。

联系方式

如果您有任何疑问、建议或问题,请在issues留言。

format-json-utils's People

Contributors

jamie6689 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.