Json fixes

proper nesting and escaping. Also squish a couple bad examples uses of encode