Skip to content
 
 

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

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages