code: private static String[] splitArgs(String argStr) {
      StringBuilder sb = new StringBuilder(argStr);
      StringBuilder arg = new StringBuilder();
      List<String> splitArgList = new ArrayList<String> ();
      boolean inDoubleQuotes = false;
      boolean inSquareBrackets = false; // for arrays of arrays
  
      for (int i=0; i < sb.length(); i++) {
        if (sb.charAt(i) == '"' && !inDoubleQuotes && !inSquareBrackets) {
          inDoubleQuotes = true;
          arg.append(sb.charAt(i));
        } else if (sb.charAt(i) == '"' && inDoubleQuotes && !inSquareBrackets) {
          inDoubleQuotes = false;
          arg.append(sb.charAt(i));
        } else if (sb.charAt(i) == ',' && !inDoubleQuotes && !inSquareBrackets) {
          splitArgList.add(arg.toString());
          // clear the field for next word
          arg.setLength(0);
        } else if (sb.charAt(i) == '[') {
          inSquareBrackets = true;
          arg.append(sb.charAt(i));
        } else if (sb.charAt(i) == ']') {
          inSquareBrackets = false;
          arg.append(sb.charAt(i));
        } else {
          arg.append(sb.charAt(i));
        }
      }
      if (arg.length() > 0)
        splitArgList.add(arg.toString());
  
      return splitArgList.toArray(new String[splitArgList.size()]);
    }
docs: TODO: detect and complain about malformed JSON