微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

λJSON JSON 替代

程序名称:λJSON

λJSON 介绍

λJSON 是 JSON 的嵌入式替代品,它可以让你解析和字符串化纯函数及其内容。

示例代码:

var LJSON = require("LJSON");// `newPlayer` is a function and couldn't be serialized with JSON.function newPlayer(name){    return {
        name      : name,
        hp        : 12,
        atk       : 5,
        def       : 5,
        inventory : []}
};
// LJSON has no trouble doing it because `newPlayer` is pure.
var newPlayerSource = LJSON.stringify(newPlayer); 
var John            = LJSON.parse(newPlayerSource)("John");console.log("Serialized λJSON: " + newPlayerSource);console.log("Parsed and applied: " + John);

λJSON 官网

https://github.com/MaiaVictor/LJSON

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐