src/main/java/tinyrtpl/Data.java
public String toJsonString() {
        switch (this.type) {
            case 0:
                return "null";
            case 1:
            case 2:
            case 3:
                return this.toString();
            case 4:
                return "\"" + StringEscapeUtils.escapeJson(this.toString()) + "\"";
            case 5:
                if(this.vmap == null) return "null";
                StringBuilder sb = new StringBuilder("{");
                Iterator it = this.vmap.entrySet().iterator();
                boolean notEmpty = false;
                while (it.hasNext()) {
                    notEmpty = true;
                    Map.Entry e = (Map.Entry) it.next();
                    sb.append("\"" + StringEscapeUtils.escapeJson((String) e.getKey()) + "\":" + ((Data) e.getValue()).toJsonString()  + ",");
                }
                if(notEmpty) {
                    sb.deleteCharAt(sb.length() - 1);
                }
                sb.append("}");
                return sb.toString();
            case 6:
                if(this.varray == null) return "null";
                StringBuilder sb1 = new StringBuilder("[");
                boolean notEmpty1 = false;
                for(Data dt : this.varray) {
                    notEmpty1 = true;
                    sb1.append(dt.toJsonString() + ",");
                }
                if(notEmpty1) {
                    sb1.deleteCharAt(sb1.length() - 1);
                }
                sb1.append("]");
                return sb1.toString();
            default:
                return "";
        }
    }
/**
     * Return the json string format of a given Object.
     * @return json string of the Object
     */
Return the json string format of a given Object.
@return json string of the Object
Return the json string format of a given Object . @return json string of the Object
public String toJsonString() {
        switch (this.type) {
            case 0:
                return "null";
            case 1:
            case 2:
            case 3:
                return this.toString();
            case 4:
                return "\"" + StringEscapeUtils.escapeJson(this.toString()) + "\"";
            case 5:
                if(this.vmap == null) return "null";
                StringBuilder sb = new StringBuilder("{");
                Iterator it = this.vmap.entrySet().iterator();
                boolean notEmpty = false;
                while (it.hasNext()) {
                    notEmpty = true;
                    Map.Entry e = (Map.Entry) it.next();
                    sb.append("\"" + StringEscapeUtils.escapeJson((String) e.getKey()) + "\":" + ((Data) e.getValue()).toJsonString()  + ",");
                }
                if(notEmpty) {
                    sb.deleteCharAt(sb.length() - 1);
                }
                sb.append("}");
                return sb.toString();
            case 6:
                if(this.varray == null) return "null";
                StringBuilder sb1 = new StringBuilder("[");
                boolean notEmpty1 = false;
                for(Data dt : this.varray) {
                    notEmpty1 = true;
                    sb1.append(dt.toJsonString() + ",");
                }
                if(notEmpty1) {
                    sb1.deleteCharAt(sb1.length() - 1);
                }
                sb1.append("]");
                return sb1.toString();
            default:
                return "";
        }
    }
public String toJsonString ( ) { switch ( this . type ) { case 0 : return "null" ; case 1 : case 2 : case 3 : return this . toString ( ) ; case 4 : return "\"" + StringEscapeUtils . escapeJson ( this . toString ( ) ) + "\"" ; case 5 : if ( this . vmap == null ) return "null" ; StringBuilder sb = new StringBuilder ( "{" ) ; Iterator it = this . vmap . entrySet ( ) . iterator ( ) ; boolean notEmpty = false ; while ( it . hasNext ( ) ) { notEmpty = true ; Map . Entry e = ( Map . Entry ) it . next ( ) ; sb . append ( "\"" + StringEscapeUtils . escapeJson ( ( String ) e . getKey ( ) ) + "\":" + ( ( Data ) e . getValue ( ) ) . toJsonString ( ) + "," ) ; } if ( notEmpty ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } sb . append ( "}" ) ; return sb . toString ( ) ; case 6 : if ( this . varray == null ) return "null" ; StringBuilder sb1 = new StringBuilder ( "[" ) ; boolean notEmpty1 = false ; for ( Data dt : this . varray ) { notEmpty1 = true ; sb1 . append ( dt . toJsonString ( ) + "," ) ; } if ( notEmpty1 ) { sb1 . deleteCharAt ( sb1 . length ( ) - 1 ) ; } sb1 . append ( "]" ) ; return sb1 . toString ( ) ; default : return "" ; } }
Return the json string format of a given Object.
Return the json string format of a given Object .