Skip to content
forked from huntbao/jsonbean

Extract datatypes from java bean files using pegjs.

License

Notifications You must be signed in to change notification settings

NEYouFan/jsonbean

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
      }
   ]
}

About

Extract datatypes from java bean files using pegjs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 74.2%
  • JavaScript 25.8%