Re: EuMVC:Map to Json
- Posted by ghaberek (admin) Jan 07, 2022
- 757 views
You're right, there should be, but Euphoria isn't typed strongly enough to make a one-to-one translation from a map to JSON, so some type information has to be specified manually.
What I did, at least when parsing json and not that it has anything to do with maps, dunno if this will help:
•Numbers and Strings (without quotes) are held natively
•An object is held as a sequence with a first element of -1 (JSON_OBJECT),and the rest pairs, the first of which is a string and the second any of these types.
•An array is held as a sequence with a first element of -2 (JSON_ARRAY),and the rest any of these types.
•A keyword is held as a sequence with a first element of -3 (JSON_KEYWORD),and one of the strings "true", "false", or "null".
That does help. I may use this approach when I pull the JSON parser over from EuMVC into Euphoria standard library, which I'm hoping to do for 4.2 release. Thanks!
-Greg