Simplify code in AS json encoder