1. JSON and euphoria
- Posted by robsteele Apr 26, 2010
- 1777 views
so i was thinking, i haven't seen a JSON encode/decode lib for eu. I'm thinking into it and am having a problem with the design. A JSON object can be an associative arr, and currently there is no standard for the representation of that. ie JSON
{"foo" : "bar"}
problem is that's easy to rep as a sequence ie
but what happens when you have a JSON object with an array also
{
'foo' :'bar',
'users' : ['user1', 'user2']
}
{{'foo', 'bar'}, {'users', {'user1', 'user2'} } }
the array will be treated as an associative one.
so the question is, how to rep json code succinctly in a sequence so as to recreate the original.
2. Re: JSON and euphoria
- Posted by jimcbrown (admin) Apr 26, 2010
- 1801 views
so i was thinking, i haven't seen a JSON encode/decode lib for eu. I'm thinking into it and am having a problem with the design. A JSON object can be an associative arr, and currently there is no standard for the representation of that. ie JSON {"foo" : "bar"} problem is that's easy to rep as a sequence ie but what happens when you have a JSON object with an array also { 'foo' :'bar', 'users' : ['user1', 'user2'] } {{'foo', 'bar'}, {'users', {'user1', 'user2'} } } the array will be treated as an associative one. so the question is, how to rep json code succinctly in a sequence so as to recreate the original.
I think the answer is to represent the JSON using a library that provides associative arrays. Let the associative array library deal with how to represent the associative array as a sequence, then your code just deals with representing a JSON object as an associative array.
3. Re: JSON and euphoria
- Posted by petelomax Apr 26, 2010
- 1732 views
I have to agree with jimcbrown, while Eu sequences are good, associative arrays they are not. This has piqued my interest; I would be mildly interested in helping out where I can, but the devil in the details here is how one might hold nested associative arrays.
4. Re: JSON and euphoria
- Posted by DerekParnell (admin) Apr 27, 2010
- 1715 views
This has piqued my interest; I would be mildly interested in helping out where I can, but the devil in the details here is how one might hold nested associative arrays.
I started a JSON module sometime back. I can dig it out and finish it off, if there's an interest.
In general, I represented JSON data like this ...
Data :: Object | Boolean | Number | Text | Array String :: { integer, ... } Object :: { String , Data } Boolean :: { 'b', integer } Number :: { 'n', atom } Text :: { 't', String } Array :: { 'a', { Object, ... }}
5. Re: JSON and euphoria
- Posted by petelomax Apr 29, 2010
- 1606 views
I started a JSON module sometime back. I can dig it out and finish it off, if there's an interest.
I guess not. While mildly interested in the technical details, I have no actual use for a JSON module.