Giter Site home page Giter Site logo

kevin-wang001 / mockj Goto Github PK

View Code? Open in Web Editor NEW
30.0 1.0 15.0 83 KB

:boom: generate mock data with specified template. 生成mock数据的利器,mockjs的java实现。同时内置随机 random 一个对象的功能。OSSRH-56437

License: Apache License 2.0

Java 100.00%
mock mockjs mockjenerator mock-data

mockj's Issues

Array处理存在与文档不一致的地方

ArrayHandler的55-67行建议改成如下所示:

        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i < option.getRule().getCount(); i++) {
            JSONArray templates = (JSONArray) option.getTemplate();
            if (templates.size() > 1) {
                int index = 0;
                for (Object template : templates) {
                    jsonArray.add(CatMockHandler.gen(template, Integer.toString(index), option.getContext()));
                    index++;
                }
            } else if (templates.size() == 1) {
                jsonArray.add(CatMockHandler.gen(templates.get(0), "0", option.getContext()));
            }
        }
        return jsonArray;

当前从gitee上拉的最新代码处理数组时会增加一层[],如下所示:

//input
{
  "array|3": [{    
     "Hello":"Hello",
    "Mock.js":"Mock.js",
    "!":"!"
  }]
}
//output
{
  "array": [[{    
     "Hello":"Hello",
    "Mock.js":"Mock.js",
    "!":"!"
  }],
[{    
     "Hello":"Hello",
    "Mock.js":"Mock.js",
    "!":"!"
  }],
[{    
     "Hello":"Hello",
    "Mock.js":"Mock.js",
    "!":"!"
  }]]
}

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.