Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added. Warning: This method assumes that the data structure is acyclical. @return The writer. @throws JSONException
(Writer writer)
| 894 | * @throws JSONException |
| 895 | */ |
| 896 | public Writer write(Writer writer) throws JSONException { |
| 897 | try { |
| 898 | boolean b = false; |
| 899 | int len = length(); |
| 900 | |
| 901 | writer.write('['); |
| 902 | |
| 903 | for (int i = 0; i < len; i += 1) { |
| 904 | if (b) { |
| 905 | writer.write(','); |
| 906 | } |
| 907 | Object v = this.myArrayList.get(i); |
| 908 | if (v instanceof JSONObject) { |
| 909 | ((JSONObject)v).write(writer); |
| 910 | } else if (v instanceof JSONArray) { |
| 911 | ((JSONArray)v).write(writer); |
| 912 | } else { |
| 913 | writer.write(JSONObject.valueToString(v)); |
| 914 | } |
| 915 | b = true; |
| 916 | } |
| 917 | writer.write(']'); |
| 918 | return writer; |
| 919 | } catch (IOException e) { |
| 920 | throw new JSONException(e); |
| 921 | } |
| 922 | } |
| 923 | } |
no test coverage detected