GithubHelp home page GithubHelp logo

anthonycarl / nodatime.serialization.servicestacktext Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 4.0 52.13 MB

ServiceStack.Text support for NodaTime.

License: BSD 2-Clause "Simplified" License

PowerShell 9.40% C# 90.58% Batchfile 0.03%

nodatime.serialization.servicestacktext's People

Contributors

anthonycarl avatar jasonauk avatar tvjames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nodatime.serialization.servicestacktext's Issues

Support for ServiceStack.Text >= 4.0.42

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

how to deserialize null LocalDate from csv data

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; }
}

LocalDates not deserialising using ServiceStack.Text (v3) in with WebApi.

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.