Adjusted metaToJSON to use inline writer.