根据条件 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

数据挖掘导论

数据挖掘导论

Pang-Ning Tan, Michael Steinbach / 范明 范宏建 / 人民邮电出版社 / 2006-01-01 / 49.00元

本书全面介绍了数据挖掘的理论和方法,旨在为读者提供将数据挖掘应用于实际问题所必需的知识。本书涵盖五个主题:数据、分类、关联分析、聚类和异常检测。除异常检测外,每个主题都包含两章:前面一章讲述基本概念、代表性算法和评估技术,后面一章较深入地讨论高级概念和算法。目的是使读者在透彻地理解数据挖掘基础的同时,还能了解更多重要的高级主题。此外,书中还提供了大量示例、图表和习题。 本书适合作为......一起来看看 《数据挖掘导论》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具