Comments (8)
@jbattermann You need to tell Jil to include inherited members. You can do this by either passing Options.IncludeInherited
or by creating your own Options object with includeInherited:true
to pass.
With Options.IncludeInherited
passed on line 32 your gist will serialize to:
{"User":{"CreatedAtUtc":"\/Date(1388581200000)\/","DateOfBirth":"\/Date(315550800000)\/","UserId":1,"Username":"SomeUsername"}}
By default inherited fields aren't included as, at least for the roles Jil was envisioned for in my projects, it's often unwanted behavior. It's there if you need it though.
from jil.
Ah I see - thanks for the clarification. Good stuff. Thanks Kevin!
from jil.
@kevin-montrose one question regarding the same 'area':
Options.IncludeInherited did in fact add the inherited properties in the serialized Json, but it doesn't work the other way around - if I pass in the same Options to the .Deserialize(..) call, the nested property is returned as 'null'.
I've read over the documentation but saw nothing that would indicate why it's leaving out that property (but it does mention the originally overlooked Optiones.IncludeInherited, sorry for asking what was clearly indicated :-/).
I've updated the gist and marked the line (see https://gist.github.com/jbattermann/9589865db33742e2280b#file-deepobjectgraphtests-cs-L45), maybe you can give me a push in the right direction. Thanks!
from jil.
@jbattermann that may be an actual bug, I don't have time to dig in right this second but I'll try and set aside some time this week for it.
from jil.
Thanks @kevin-montrose , highly appreciated! Let me know if you need any more samples/input or whatsoever.
from jil.
Fix is here
from jil.
#76 merged in
from jil.
Thanks Kevin & @manofstick !
from jil.
Related Issues (20)
- Jil can't serialize this string
- Should Version 2.16 Have Been a Major Version?
- OutOfMemoryException HOT 1
- Can't edit Deserialized child Object
- Can't determine deserialized dynamic object type.
- Can I control the precision of decimals?
- Unexpected end of stream HOT 2
- Rejects valid JSON
- Deserialize crashes under .Net 5 HOT 2
- InvalidProgramException when serializing types containing JilPrimitiveWrappers
- Performance decrease when called from anonymous function
- [Deserialization] Exception: `Expected digit`
- Trying to add dll that Jil uses to the database like to CLR
- PlatformNotSupportedException HOT 1
- Using Jil with ASP.NET Core 6 HOT 1
- Class Not serialized
- Set package metadata
- Add additional TFM to eliminate dependency
- Does exist the possibility to serialize object to bytes array (as Utf8Json forexample)?
- Can not deserialize on .net 9
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 jil.