1. JSON and euphoria

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 'foo','bar'
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.

new topic     » topic index » view message » categorize

2. Re: JSON and euphoria

robsteele said...

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 'foo','bar' 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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: JSON and euphoria

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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: JSON and euphoria

petelomax said...

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, ... }}  

new topic     » goto parent     » topic index » view message » categorize

5. Re: JSON and euphoria

DerekParnell said...

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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu