Comments (2)
You're right, we don't go more than one level deep. I can look in to this.
from ronin.
It'd be nice if you could either/or it: either embed an ID in the "fromID" attribute or, if that isn't present, then new up the object and reflect.
Here is the code that I sent to the interns, which appears to kind of work:
function deserializeJSON( str : String, rootType : Type ) : T {
var x = new JSONReader()
var root = x.read( str )
return transformObj( root, rootType ) as T
}
function transformObj( val : Object, type : Type ) : Object {
if( val typeis Map ) {
var instance = type.TypeInfo.getConstructor( {} ).Constructor.newInstance( {} )
val.eachKeyAndValue( \ propName, propVal -> {
var prop = type.TypeInfo.getProperty( propName as String )
if( prop.Writable ) {
prop.Accessor.setValue( instance, CommonServices.getCoercionManager().convertValue( transformObj( propVal, prop.FeatureType ), prop.FeatureType ) )
}
})
// maybe commit object here?
return instance
} else if( val typeis List ) {
return val.map( \ o -> transformObj( o, type.TypeParameters.first() ) )
} else {
print( "expected: ${type.Name}, found ${typeof val}" )
return val
}
}
Obviously it needs to be more robust (list handling is very raw, error handling is non-existant, should we commit the db objects to the db up front? If not, how can a user figure out what to commit?) but at least the reflection appears to work reasonably well.
Cheers,
Carson
On Jun 9, 2011, at 8:20 AM, kprevas wrote:
You're right, we don't go more than one level deep. I can look in to this.
Reply to this email directly or view it on GitHub:
#44 (comment)
from ronin.
Related Issues (20)
- 27 - show cache hits/misses HOT 1
- investigate OpenID integration HOT 2
- investigate OAuth integration
- possibly integrate httpclient
- provide optional URL rewriting layer HOT 1
- annotation for "protected" properties HOT 1
- can't call static method with optional parameters HOT 1
- set content-type correctly on JSONP response HOT 1
- classpath for roninint created project isn't setup right (at least in Windows) HOT 3
- fix verify-app HOT 1
- UI testing support?
- pull out testing support classes to separate jar HOT 1
- rudimentary load testing framework
- make parameter handling and return value handling pluggable
- see if using protocols to reduce reflective method invocation improves performance HOT 2
- make HttpsOnly redirect instead of 500
- Quotes Required in SQL statements against H2. HOT 13
- Error when trying to initialize an app HOT 5
- Can not create project using archetype HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ronin.