On 10 Jul 2006, [EMAIL PROTECTED] wrote:

> Any ideas on the format for these?  For example, I've got a
> column_values_as_yaml() helper method like this:
>
> $o = My::Object->new(a => 1, b => 2, c => 3);
>
> print $o->column_values_as_yaml;
>
> which prints:
>
> a: 1
> b: 2
> c: 3
>
> But then what should the as_yaml() helper do?  The same thing?  Or
> should the class name be in there somewhere?
>
> My::Object:
> a: 1
> b: 2
> c: 3

I don't use YAML (and I think very few do) so no opinion.  I would
recommend some kind of column info separate from the data, as below.

> I have similar questions for as_json().  How should this work?

I would use the following.  At least in my experience, it would make
it easier to do real work.  Otherwise you need a separate
as_json_metadata() method, or you need to hard-code the metadata.

print $o->as_json();

{
 "object_info": { type: "My::Object" },
 "columns": [ [ "a", { "type": "Integer", "maxlen": 20} ],
              [ "b", { "type": "Integer", "maxlen": 10} ],
              [ "c", { "type": "Integer", "maxlen": 5}  ]
            ],
 "data": [ 1, 2, 3 ]
}

I don't know JavaScript very well, so perhaps the type and other info
can be expressed differently, but this kind of metadata would work for
me.  The extra data for the columns and in object_info should be
extensible and optional, except for 'type'.  I would definitely prefer
ordered output in arrays, instead of a hash with column names as keys.

Since XML is a fairly neutral data language (and can be used instead
of JSON in JavaScript in many cases), perhaps XML should be the first
format produced, and JSON and YAML can be modeled after it.

Ted


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to