General JSON encoder, backend done!