added mostly functional JSON api