1.0.5 • Published 4 years ago

jsonbean v1.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

jsonbean

Extract datatypes from java bean files using pegjs.

Installation

Node.js:

$ npm install jsonbean --save

Usage

let jsonbean = require('jsonbean')
let beanStr = 'SOME JAVA BEAN String'
let result = jsonbean.parse(beanStr)

If you want to use it in browser, download src/jsonbean.pegjs, use pegjs to compile it.

First, you should install pegjs:

$ npm install -g pegjs

Then, for example, the browser global variable you wanted is window.jsonbean, run command as follows:

$ pegjs --format globals jsonbean.pegjs

You can run some tests defined in the __tests__ directory by the command:

$ npm run test

Example

Input java bean string:

package com.example.test;

/*
 * User bean
 */
public class User {
    /*
     * user id
     */
    private String id;
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
}

Output json:

{
   "name": "User",
   "description": "User bean",
   "attributes": [
      {
         "name": "id",
         "type": "String",
         "isArray": false,
         "defaultValue": "",
         "description": "user id"
      }
   ]
}
1.0.5

4 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago