根据条件 JSON 生成随机 JSON randomjson

码农软件 · 软件分类 · JSON/BSON开发包 · 2019-03-30 20:12:05

软件介绍

randomjson,前端 mock 利器。可根据条件 json 生成随机 json。

用法

    // 在amd,cmd环境中,引用包,在浏览器中无需引用
    
    var randomjson = require('randomjson');
    
    // 模型
    var modelJson = {
        "code": "00",
        "numberCode": "<@[10000,20000]>",
        "msg": "<@chinese{12,50}>",
        "msg2": "<@string{2,3}>",
        "logo": "<@image{100,100}>",
        "result": {
            "pList<@{1,3}>":[ 
                {
                    "indexToString": "<@index><@>",
                    "index": "<@index>",
                    "id": "<@[1-5]>", 
                    "price": "<@float>",
                    "name": "公司名称<@index>",
                    "person": "李文武<@index>",
                    "address": "北京市海淀区西三旗",
                    "mobile": "1<@number{10}>",
                    "tel": "<@number{4}>-<@number{8}>",
                    "list": [
                        {
                            "auditKey": 1,
                            "auditValue": "<@[0,1,2]>"
                        }, 
                        {
                            "auditKey": 2,
                            "auditValue": "<@[0,1,2]>"
                        }
                    ]
                }
            ]
        }
    }
    // 根据模型生成json
    var myJson = randomjson(modelJson);
    
    根据上边模型生成的json可能是这样:
    
    {
        "code": "00",
        "numberCode": 10000,
        "msg": "加义为边平压你治提用根治问求只或程干立农资特",
        "msg2": "dv",
        "logo": "https://dummyimage.com/100x100",
        "result": {
            "pList": [
                {
                    "indexToString": "1",
                    "index": 1,
                    "id": 2,
                    "price": 93.78,
                    "name": "公司名称1",
                    "person": "李文武1",
                    "address": "北京市海淀区西三旗",
                    "mobile": "17929438781",
                    "tel": "1148-56055642",
                    "list": [
                        {
                            "auditKey": 1,
                            "auditValue": 0
                        },
                        {
                            "auditKey": 2,
                            "auditValue": 1
                        }
                    ]
                },
                {
                    "indexToString": "2",
                    "index": 2,
                    "id": 5,
                    "price": 29.49,
                    "name": "公司名称2",
                    "person": "李文武2",
                    "address": "北京市海淀区西三旗",
                    "mobile": "17826945504",
                    "tel": "7298-46226026",
                    "list": [
                        {
                            "auditKey": 1,
                            "auditValue": 0
                        },
                        {
                            "auditKey": 2,
                            "auditValue": 0
                        }
                    ]
                }
            ]
        }
    }

本文地址:https://codercto.com/soft/d/2508.html

算法设计与分析

算法设计与分析

王红梅 / 清华大学 / 2006-7 / 23.00元

《算法设计与分析》(普通高校本科计算机专业特色教材精选)将计算机经典问题和算法设计技术很好地结合起来,系统地介绍了算法设计技术及其在经典问题中的应用。全书共12章,第1章介绍了算法的基本概念和算法分析方法,第2章从算法的观点介绍了NP完全理论,第3章~~第11章分别介绍了蛮力法、分治法、减治法、动态规划法、贪心法、回溯法、分支限界法、概率算法和近似算法等算法设计技术,第12章基于图灵机计算模型介绍......一起来看看 《算法设计与分析》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器