Here you can find the source of splitJsonObjects(String string)
protected static List<String> splitJsonObjects(String string)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { protected static List<String> splitJsonObjects(String string) { List<String> jsonObjects = new ArrayList<String>(); int brackets = 0; int start = 0; for (int i = 0; i < string.length(); i++) { switch (string.charAt(i)) { case '{': brackets++;//from w ww. j a v a 2 s . c o m if (brackets == 1) start = i; break; case '}': brackets--; if (brackets < 0) { jsonObjects.clear(); // we started in the middle of a json // object brackets = 0; } else if (brackets == 0) { jsonObjects.add(string.substring(start, i + 1)); } break; default: break; } } return jsonObjects; } }