JSON reimplemented (moved from cwt-core project).