Reimplement ejson in order that it can encode and decode records properly