problem solved. I was not aware of the cool qooxdoo class qx.utils.Json.
There is a method of the class that is working perfect,
qx.util.Json.stringify().
If you have not tried this, it seems to work great.
Thanks,
Jim


On Tue, Mar 3, 2009 at 11:27 AM, Jim Hunter <[email protected]> wrote:

> I am trying to modify prototypes of some base JavaScript classes and
> running into an issue with qqoxdoo. First off, I know you shouldn't modify
> base classes but for what I am doing I don't see a way around it. I got some
> routines off the web that allow me to clone objects. More specifically they
> allow me to clone JSON objects. But in order to do that I need to modify
> Object/String/etc. to give them a new method, toJSON. If I use the qooxdoo
> playground and run my code inside it I can make things work. If I run the
> code in FireBug after my application is loaded, it works fine. But if I tack
> the code to the end of my large JS file, or if I attempt to load it after my
> application appears, I get the following error:
> appender[id].process is not a function
>
> And at this point my application does not run.
>
> Does anyone know what might be happening? Or if anyone knows of a qooxdoo
> friendly way to clone JSON object that would be great.
>
> Here is the simple code I am loading:
>
>
> Object.prototype.deep_clone = function(){
> eval("var tmp = " + this.toJSON());
> return tmp;
> }
> Object.prototype.toJSON = function(){
> var json = [];
> for(var i in this){
>  if(!this.hasOwnProperty(i)) continue;
> //if(typeof this[i] == "function") continue;
>  json.push(
> i.toJSON() + " : " +
> ((this[i] != null) ? this[i].toJSON() : "null")
>  )
> }
> return "{\n " + json.join(",\n ") + "\n}";
> }
> Array.prototype.toJSON = function(){
> for(var i=0,json=[];i<this.length;i++)
> json[i] = (this[i] != null) ? this[i].toJSON() : "null";
>  return "["+json.join(", ")+"]"
> }
>
> String.prototype.toJSON = function(){
> return '"' +
>  this.replace(/(\\|\")/g,"\\$1")
> .replace(/\n|\r|\t/g,function(){
>  var a = arguments[0];
> return  (a == '\n') ? '\\n':
> (a == '\r') ? '\\r':
>  (a == '\t') ? '\\t': ""
> }) +
> '"'
> }
> Boolean.prototype.toJSON = function(){return this}
> Function.prototype.toJSON = function(){return this}
> Number.prototype.toJSON = function(){return this}
> RegExp.prototype.toJSON = function(){return this}
>
>
>
> Thanks,
> Jim
>
>
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to