Hi Martin,
I have a mapping containing different kind of objects. In order to succesfully deserialize any object. I need to know the 'original' type of the object to put in the XML so that the receiving/deserializing language knows whether 1 is a string or an int.
As long as the object has a value, there's no problem, but when a string is NULL, the receiving/deserializing language might still want to know the type, Especially if it concerns a 'custom' class definition.
If I store a NULL instance of MyClass, I'd like to know it was of type MyClass and not 'mixed'.
Does this clarify my problem?
On 14-1-2011 11:27, Martin Bähr wrote:
On Fri, Jan 14, 2011 at 10:42:52AM +0100, Coen Schalkwijk wrote:
...bumped right into a new problem:
mapping(string:mixed) map = ([]); string s; map["test_null"] = s; _typeof(map["test_null"]);
zero
which is fine by me, but:
typeof(map["test_null"]);
mixed
which is not so nice :( and if the variable s has a value:
why?
map["test_null"] = "no_so_null"; typeof(map["test_null"]);
mixed
but then: _ typeof(map["test_null"]);
string
this is the expected behaviour. typeof() gives the type of the variable which you above defined as mixed. _typeof() gives the type of the value, which, as we can see, is a string.
Am I asking something extremely stupid if I'd like to know if it's possible to determine the (original) type of the string in the mapping?
what do you mean by original type?
greetings, martin.