[whatwg] asynchronous JSON.parse

David Rajchenbach-Teller dteller at mozilla.com
Fri Mar 8 13:16:59 PST 2013

On 3/8/13 5:35 PM, David Bruant wrote:
>> Intuitively, this sounds like:
>> 1. collect data to a JSON;
> I don't understand this sentence. Do you mean "collect data in an object"?

My bad. I sometimes write "JSON" for "object that may be stringified to
JSON format and parsed back without loss", i.e. a bag of [bags of]
non-function properties. So let's just say "object."

>> 2. serialize JSON (hopefully asynchronously) to a Transferable (or
>> several Transferables).
> Why not collect the data in a Transferable like an ArrayBuffer directly?
> It skips the additional serialization part. Writing a byte stream
> directly is a bit hardcore I admit, but an object full of setters can
> give the impression to create an object while actually filling an
> ArrayBuffer as a backend. I feel that could work efficiently.

I suspect that this will quickly grow to either:
- an API for serializing an object to a Transferable or a stream of
Transferable; or
- a lower-level but equivalent API for doing the same, without having to
actually build the object.

For instance, how would you serialize something as simple as the following?

  name: "The One",
  hp: 1000,
  achievements: ["achiever", "overachiever", "extreme overachiever"]
   // Length of the list is unpredictable

> What are the data you want to collect? Is it all at once or are you
> building the object little by little? For a backup and for FirefoxOS
> specifically, could a FileHandle [3] work? It's an async API to write in
> a file.

Thanks for the suggestion. I am effectively working on refactoring
storing browser session data. Not for FirefoxOS, but for Firefox
Desktop, which gives me more architectural constraints but frees my hand
to extend the platform with additional non-web libraries.

Best regards,

David Rajchenbach-Teller, PhD
 Performance Team, Mozilla

More information about the whatwg mailing list