JSON help

I'm trying to generate and parse JSON inside of an AS application. As part of that I've submitted a PR to assemblyscript-json to properly escape reserved characters in JSON . And I feel pretty good about doing it the way I did (doing the escaping in JSON.Str.toString()), because the code below returns {"foo":1}:

import { JSON } from 'assemblyscript-json'

function(): string {
  const obj = new JSON.Obj()
  obj.set('foo', 1)
  return obj.toString()
}

But I feel like maybe there was a better place to put that, or a more elegant way to do it.

I guess what I'm asking for is code reviews from Internet randos :)

Posted Dec 3, 2020, 10:42 PM UTC

20

No comments yet

Nobody commented on this post, or the comments weren't captured.