rokucommunity / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
4 stars 2 forks source link

Add support for `formatJson()` undocumented flags 256 and 512 #76

Closed lvcabral closed 1 month ago

lvcabral commented 2 months ago

From the community slack by @TwitchBronBron :

The docs for FormatJson(json as Object, flags = 0 as Integer) as String is missing information on some of the flags. For example, flag 256 which converts non-serializable values into null rather than printing a parse error and returning invalid. Could we get those docs updated with all the supported flags? https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#formatjsonjson-as-object-flags--0-as-integer-as-string

Quote from Slack by @unwiredben

The undocumented flags for FormatJson are 256 - UnsupportedIgnore and 512 - UnsupportedAnnotate - these control what happens when an object in the AA isn't something that can be represented by JSON, like a roWhatever instance. Ignore just has it output as a null, while Annotate makes it a JSON string of the format "".