anthonycarl / nodatime.serialization.servicestacktext Goto Github PK
View Code? Open in Web Editor NEWServiceStack.Text support for NodaTime.
License: BSD 2-Clause "Simplified" License
ServiceStack.Text support for NodaTime.
License: BSD 2-Clause "Simplified" License
Hi,
Recently updated our project to use latest ServiceStack release which caused an issue with current 1.2.17 version from NuGet as latest ServiceStack.Text does not have .net3.5-clientprofile.
I've forked and added support for it here: https://github.com/nvisage-gf/NodaTime.Serialization.ServiceStackText/tree/feature/ServiceStack_v4.0.42
Updated to .NET 4.0 profile and latest ServiceStack.Text + NodaTime assemblies.
NuGet (beta) package on our MyGet feed here: http://www.symbolsource.org/MyGet/Metadata/nvisage-psm/Project/NodaTime.Serialization.ServiceStackText
I can submit pull request if required; though you may want to review changes before.
Regards,
Gavin
Hello!
I'm just trying to get a feel for this library. I need some guidance on how to get the marked code below to not throw exception when deserializing null data to a null LocalDate. what might be the easiest workaround?? thank you for helping!
static void NodaTimeModelCsvTest()
{
//one-time setup to register NodaTime serializers with ServiceStack
DateTimeZoneProviders.Tzdb
.CreateDefaultSerializersForNodaTime()
.ConfigureSerializersForNodaTime();
var nodatimeModels = new List<NodaTimeModel>();
var data = new List<NodaTimeModel>()
{
new NodaTimeModel { CreatedAt = LocalDate.FromDateTime(DateTime.Now), CreatedBy = "one"},
new NodaTimeModel { CreatedAt = LocalDate.FromDateTime(DateTime.Now), CreatedBy = "two"},
new NodaTimeModel { CreatedAt = null, CreatedBy = "evan"}
};
var str = CsvSerializer.SerializeToCsv<NodaTimeModel>(data);
nodatimeModels = str.FromCsv<List<NodaTimeModel>>(); //****this throws cannot be null exception; would like it to be ok to deserialize into a null LocalDate
}
}
public class NodaTimeModel
{
public int Id { get; set; }
public LocalDate? CreatedAt { get; set; }
public string CreatedBy { get; set; }
}
I am attempting to use deserialise noda* objects with ServiceStack.Text and your library (from nuget), however it is not deserialising correctly.
I am setting it up WebApi like this:
public static void Register(HttpConfiguration config)
{
JsConfig.DateHandler = JsonDateHandler.ISO8601;
DateTimeZoneProviders.Tzdb
.CreateDefaultSerializersForNodaTime()
.ConfigureSerializersForNodaTime();
config.Formatters.RemoveAt(0);
config.Formatters.Insert(0, new ServiceStackTextFormatter());
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional });
}
This serialises fine, but fails to deserialise any noda* objects. Do you have any tips or suggestions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.