Here you can find the source of splitObjectString(String str)
public static String[] splitObjectString(String str)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static String[] splitObjectString(String str) { List<String> ret2 = new ArrayList<String>(); int i;/*from w ww .j a va2 s. c o m*/ char chr; int ignoreValue = 0; StringBuilder strBuf = new StringBuilder(); boolean ignStr = false; for (i = 0; i < str.length(); i++) { chr = str.charAt(i); if (chr == '"') { ignStr = !ignStr; } if (chr == '[' || chr == '{') { ignoreValue++; } if (chr == ']' || chr == '}') { ignoreValue--; } if (ignoreValue == 0 && !ignStr && (chr == ':' || chr == ',')) { ret2.add(strBuf.toString()); strBuf = new StringBuilder(); } else { if ((int) chr != 0x20) { // ignore whitespaces TODO: ignore tabs & newlines strBuf = strBuf.append(chr); } } } ret2.add(strBuf.toString()); return ret2.toArray(new String[0]); } }