You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.
We stringify and parse JSON or POJO and convert to and from Thrift, both in Node.js to allow endpoints implementations to be shared between JSON and Thrift transport encodings, but even more importantly in TCurl for parsing arguments and formatting responses. As such, we should maximize the expressiveness of JSON as a medium for Thrift.
JSON stringify and parse are adequate for converting thrift model objects to and from their JSON/POJO form up to a point. Limitations:
i64: JavaScript’s JSON stringify and parse can only handle resolutions known by JavaScript. jq and Thrift do not have this limitation and Long.js can stringify numbers up to their full 64 bit resolution.
timestamps: We standardize timestamps in Thrift as numbers of miliseconds in 64 bit resolution to avoid slow and unnecessary date parsing and formatting. However, this format is not idiomatic or visually useful for JSON. With the i64 (js.type = 'Date') annotation and the specialized I64DateRW we have an opportunity to implement an alternate JSON representation using ISO timestamps, when both reading JSON (as with TCurl arguments) or writing (As with TCurl output).
I propose that we implement stringify(value):text and parse(text, offset):Result<value> methods on each ThriftRW to improve TCurl user experience. With this change, given a Thrift IDL with js.type annotations, it will be possible to:
pass an ISO string as an argument in the position of an i64 (js.type = 'Date')
read an i64 (js.type = 'Date') as an ISO string from TCurl and jq output.
pass an arbitrary precision number as an argument in the position of i64 types.
read an i64 with all precision in TCurl and jq output.
Likewise, due consideration can be made for binary encoding (hex or \u0000) and flexibility made for future specialization as needed.
We stringify and parse JSON or POJO and convert to and from Thrift, both in Node.js to allow endpoints implementations to be shared between JSON and Thrift transport encodings, but even more importantly in TCurl for parsing arguments and formatting responses. As such, we should maximize the expressiveness of JSON as a medium for Thrift.
JSON stringify and parse are adequate for converting thrift model objects to and from their JSON/POJO form up to a point. Limitations:
jq
and Thrift do not have this limitation and Long.js can stringify numbers up to their full 64 bit resolution.i64 (js.type = 'Date')
annotation and the specialized I64DateRW we have an opportunity to implement an alternate JSON representation using ISO timestamps, when both reading JSON (as with TCurl arguments) or writing (As with TCurl output).I propose that we implement
stringify(value):text
andparse(text, offset):Result<value>
methods on each ThriftRW to improve TCurl user experience. With this change, given a Thrift IDL with js.type annotations, it will be possible to:i64 (js.type = 'Date')
i64 (js.type = 'Date')
as an ISO string from TCurl and jq output.i64
types.i64
with all precision in TCurl and jq output.Likewise, due consideration can be made for binary encoding (hex or
\u0000
) and flexibility made for future specialization as needed.cc @abhinav @malandrew
The text was updated successfully, but these errors were encountered: