npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

genmodel

v0.0.3

Published

generate object-c model with a template

Readme

genmodel

genmodel 可以使用命令根据json文件生成object-c的model,避免重复的劳动

安装

npm install genmodel -g

如何使用

genmodel -h 可得到下面使用说明 `Usage: genmodel [options]

Options:
  -i, --inPath        the json source file path              [string] [required]
  -o, --outPath       the model output file path                        [string]
  -n, --name          the name of the root model,will apply prefix or suffix for
                      root model and all nest models if exists
                                                             [string] [required]
  -p, --class_prefix  the model className of prefix                     [string]
  -s, --class_suffix  the model className of suffix                     [string]
  -k, --key           the key path for json object to generate model         [string]
  -m, --class_map     the map className for the nest object or array; use -m
                      ".products=product",also apply prefix or suffix   [string]
  -t, --template      the template for modelClass,use "iPadModel" or "YYModel"
                      or custom template path,default "iPadModel"       [string]
  -h, --help          Show help                                        [boolean]

Examples:
  genmodel -n User -p XX -s Model -i xxx.json -o ~/Desktop 
  generate XXUserModel with the xxx.json to Desktop

copyright 2016`

###注意事项

  • prefix 和 suffix会应用到 name指定的className 以及 嵌套的 className
  • 自定义模板传入一个目录,命令规则为 :假设目录名XXXModel 则XXXModel 里的.h和.m文件的文件名为 XXXModelH.tpl 和 XXXModelM.tpl,模板语法参照 artTemplate
  • -k(--key)的含义为指定 根对象 所对应的键路径,例如:
{
    "orderId": 104,
    "totalPrice": 103.45,
    "products": [
        {
            "id": 123,
            "name": "Product #1",
            "price": 12.95,
            "productIn": {
                "idInArr": 123,
                "name": "Product name",
                "price": 12.95
            }
        }
    ],
    "productOut": {
        "id": 123,
        "name": "Product name",
        "price": 12.95,
		"productIn": {
                "idIn": 123,
                "name": "Product name",
                "price": 12.95
            }
    }
}

指定 -k '.products.0.productIn' -n product 则只会以productIn的json生成product类,--key 可以嵌套,以"."开头,以文件json的根对象开始遍历,数组只能指定索引为 0

  • -m(--class_map)是嵌套对象类命名映射,规则为.productOut=product,.userB=user以"."开头,可以嵌套路径,从根对象开始(如有-key,则为-key指定的根对象),以逗号分隔,中间不要留空格 如以上json 执行 genmodel -n order -i xxx.json -m '.productOut=product' 则生成order类,product类
  • -i -k 指定的json文件的根对象需为一个Dictionary