Added duration handling to jsonEncode

Signed-off-by: Tom Wright <tom@inflatablecookie.com>