Hi Ben,
Improvements would be quite welcome. We use the Tapestry JSON classes in
many places. One issue we have is that they are rather unfriendly when
it comes to parsing input received from the browser. The Tapestry class
are very much a happy path design and do not provide a means to test the
validity of data. The exceptions thrown are very generic and not much
help either.
David
On 7/25/2020 3:33 AM, Ben Weidig wrote:
Hi,
I'm thinking about improving tapestry-json but wanted to ask first if
there's actually some interest in doing so, before starting to code and
making a pull-request.
We have multiple utility classes for simpler JSON usage:
JSONArray:
- static JSONArray safeNew(String jsonStr)
- JSONArray from(Iterable<?> iterable)
- JSONArray from(Iterable<?> iterable, boolean preserveNull)
- boolean putUnique(Object obj)
- multiple typed toList(...) which might be refactored into a single
generic method
JSONObject:
- static JSONObject safeNew(String jsonStr)
- <K, V> Map<K, V> toMap(Function<String, K> keyFn, Function<Object, V>
valueFn)
- static JSONObject from(Map<String, Object> map)
JSONCollectors:
- static <T> Collector<T, JSONArray, JSONArray> toArray()
- a collector to JSONObject wasn't needed so far
Other functionality I would like to add:
- Stream-Support for JSONArray
- Safe getters, e.g., Optional<String> JSONArray#tryGet(String key),
although I haven't thought much about correct null vs NULL-sentinel
handling.
What do you think? Worth the effort, or really on utility classes?
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tapestry.apache.org
For additional commands, e-mail: dev-h...@tapestry.apache.org