NullTypes = {
PHP: {
NULL: {},
nullObj: this.NULL;
isNull: function(obj) {
},nullObj: this.NULL;
isNull: function(obj) {
return obj === this.nullObj;
}dotNET: {
isNull: function(obj) {
};SqlInt32: {
SqlString: {
Null: {},
nullObj: this.Null;
nullObj: this.Null;
isNull: function(obj) {
},return obj === this.nullObj;
}SqlString: {
Null: {},
nullObj: this.Null;
nullObj: this.Null;
isNull: function(obj) {
return obj === this.nullObj;
}},
isNull: function(obj) {
},isNull: function(obj) {
var isNull = false;
for (var p in this) {
return isNull;
}if (p != "isNull") {
}isNull = this[p].isNull(obj);
if (isNull)
}if (isNull)
break;
return isNull;
isNull: function(obj) {
var isNull = false;
for (var p in this) {
return isNull;
}if (p != "isNull") {
}isNull = this[p].isNull(obj);
if (isNull)
}if (isNull)
break;
return isNull;
then...
if (NullTypes.IsNull(foo)) {..}
On 9/22/06, Ryan Gahl <[EMAIL PROTECTED]> wrote:
NullTypes = {PHP: { NULL: {}},dotNET: {};SqlInt32: { Null: {}},}
SqlString: { Null: {}}
And then
if (foo === NullTypes.PHP.NULL) {..}
Using enumerations like this to map JSON objects to the explicit corresponding server types would allow flexibility to map to other variations that might come in and also to adapt this type of mapping to other scenarios, especially if you start wiring up to external web services on various platforms in true mashup fashion (Where the returning JSON could potentially include meta data relating to the underlying platform). But I like to mix in as much structure to this dynamic world as I can. That just comes from my background I guess and discipline. This will probably boil down to a matter of preference, like most things.On 9/22/06, Martin Bialasinski < [EMAIL PROTECTED]> wrote:
On 9/22/06, Ryan Gahl <[EMAIL PROTECTED]> wrote:
> In that case why not make your JSON output represent the sql NULLs as an
> enumeration or other mapping to the corresponding server side null
> representation.
I am afraid, I do not quite understand you. I use PHP. PHP presents a
SQL-NULL as NULL, a PHP data type. And I convert such data to JSON as
in [3, 4, 1, null, 2, 4, null]. I believe this to be quite sensible.
--
Ryan Gahl
Application Development Consultant
Athena Group, Inc.
Inquire: 1-920-954-9798 x2903
Blog: http://www.someElement.com
--
Ryan Gahl
Application Development Consultant
Athena Group, Inc.
Inquire: 1-920-954-9798 x2903
Blog: http://www.someElement.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
