@Test public void toStringOnArrayOfStrings() { JSNLst l = new JSNLst("Jarda", "Jirka", "Parda"); assertEquals(l.toString(), "{\"names\":[\"Jarda\",\"Jirka\",\"Parda\"]}", "Properly quoted"); }
@Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb.append(']'); return sb.toString(); }
JSONList extends SimpleList<T> { @Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb.append(']'); return sb.toString(); } }
JSONList extends SimpleList<T> { @Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb.append(']'); return sb.toString(); } JSONList(Proto proto, String name, int changeIndex, String... deps); }
JSONList extends SimpleList<T> { @Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb.append(']'); return sb.toString(); } JSONList(Proto proto, String name, int changeIndex, String... deps); void init(Object values); static void init(Collection<T> to, Object values); @Override boolean add(T e); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int index, Collection<? extends T> c); void fastReplace(Collection<? extends T> c); @Override boolean remove(Object o); @Override void clear(); @Override boolean removeAll(Collection<?> c); void sort(Comparator<? super T> c); @Override boolean retainAll(Collection<?> c); @Override T set(int index, T element); @Override void add(int index, T element); @Override T remove(int index); @Override String toString(); @Override JSONList clone(); }
JSONList extends SimpleList<T> { @Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb.append(']'); return sb.toString(); } JSONList(Proto proto, String name, int changeIndex, String... deps); void init(Object values); static void init(Collection<T> to, Object values); @Override boolean add(T e); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int index, Collection<? extends T> c); void fastReplace(Collection<? extends T> c); @Override boolean remove(Object o); @Override void clear(); @Override boolean removeAll(Collection<?> c); void sort(Comparator<? super T> c); @Override boolean retainAll(Collection<?> c); @Override T set(int index, T element); @Override void add(int index, T element); @Override T remove(int index); @Override String toString(); @Override JSONList clone();  }