Java Boolean Array Convert to booleanArray2Json(boolean[] array)

Here you can find the source of booleanArray2Json(boolean[] array)

Description

boolean Array Json

License

Apache License

Declaration

static String booleanArray2Json(boolean[] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static String booleanArray2Json(boolean[] array) {
        if (array.length == 0)
            return "[]";
        StringBuilder sb = new StringBuilder(array.length << 4);
        sb.append('[');
        for (boolean o : array) {
            sb.append(Boolean.toString(o));
            sb.append(',');
        }//from  w w w.  java2 s . co  m
        // set last ',' to ']':
        sb.setCharAt(sb.length() - 1, ']');
        return sb.toString();
    }
}

Related

  1. booleanArray2int(boolean[] b)