You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once time ago I wrote a XML2Js converter, and some of you helped me (at Google Group) with a function I was requiring that time, which I believe should be part of MooTools More Object.Extras.
It is a setToPath function, which basically create object paths from strings and fill it with a value.
Next, it's code:
functionsetToPath(source,path,val){varparts=key.split('.'),source2=source;// so we can return the objectfor(vari=0,l=parts.length;i<l;i++){// So when the value does not exist (and is an own property) or is not an objectif(i<(l-1)&&(!source.hasOwnProperty(parts[i])||!Type.isObject(source[i]))){source[parts[i]]={};}if(i==l-1)source[parts[i]]=val;elsesource=source[parts[i]];}// Return the modified objectreturnsource2;}
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/359991-more-object-extras-object-settopath?utm_campaign=plugin&utm_content=tracker%2F22069&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22069&utm_medium=issues&utm_source=github).
The text was updated successfully, but these errors were encountered:
Hi MooTools pals.
Once time ago I wrote a XML2Js converter, and some of you helped me (at Google Group) with a function I was requiring that time, which I believe should be part of MooTools More Object.Extras.
It is a setToPath function, which basically create object paths from strings and fill it with a value.
Next, it's code:
The text was updated successfully, but these errors were encountered: