Comments (6)
We have a lot of unit-tests, but for serialization there weren't any yet (was on the todo list ;-)). Thanks for the report, will fix it asap and create unit-tests for them.
Concerning the ToString() method. It will format Money in the current culture. If you want to format it in the culture of United States, then you should do the explicit (see https://github.com/remyvd/NodaMoney, the formatting area for examples.).
If you still think its wrong, what is the culture you are using and what do you expect in that culture? We are using the formatting that CultureInfo in .NET gives us.
from nodamoney.
Yeah, about the CultureInfo, it's true that I don't have en-US as default. :)
I was just staring blindly at your example where is said it used en-US implicitly from the current culture, only I missed "current".
from nodamoney.
Added unit-test and support for the following serializers: XmlSerializer, DataContractSerializer, DataContractJsonSerializer, Newtonsoft Json.NET & JavaScriptSerializer
NodaMoney has now a dependency on Json.Net, to support it. It's used a lot, so I took the risk to have a dependency on it. If needed this could be a separated library.
JavaScriptSerializer can only be supported by a new library NodaMoney.Serializer.AspNet. You can download the code and compile this. I will create a nuget package in the upcoming release.
You can use it by registering it, like the example below:
// create a new serializer and tell it about the NodaMoney converter.
serializer = new JavaScriptSerializer();
serializer.RegisterConverters(new JavaScriptConverter[] { new MoneyJavaScriptConverter() });
from nodamoney.
FYI - in Noda Time, we split out the JSON serializer into a separate assembly with its own nuget package. XML serialization was left in the main library.
Really though, I wouldn't bend over backwards for JavaScriptSerializer
or DataContractJsonSerializer
. Almost everything uses JSON.Net now. (IMHO)
from nodamoney.
Your right about for JavaScriptSerializer
or DataContractJsonSerializer
. Creating an own nuget package is maybe to much effort for this. it's only one class
MoneyJavaScriptConverter.cs at the moment, that people could copy or create themselves and include in their own projects, if they really need it.
I was doubting to have the Json.NET serialzier in a seperate assembly and it's own nuget package, but as you already mentioned, it's used everywhere so I took the risk by depending on it. I think people using RavenDB and MongoDB would benefit from this (need to check this).
It's not yet version 1.0, so I can pull it apart if it's not the right decision. Do you know of any other downsides, apart from a dependency, that made Noda Time to put it in a separate assambly?
from nodamoney.
The dependency was the biggest thing. There are plenty of NodaTime consumers that only use it in their business logic, and thus don't need serialization. We thought it was safe enough to support XML though, since we only have to take a dependency on System.Xml
from the framework.
WRT RavenDB, it was important to write a custom implementation so that the Noda Time types could be used in entities, indexes, and queries. I haven't done a MongoDB one yet, but it's on my list.
from nodamoney.
Related Issues (20)
- Fix for rounded value in ExchangeRate HOT 1
- Taxed money type HOT 1
- Newtonsoft Json serialization of default(Money) fails HOT 5
- Provide ExchangeRate JsonConverter out-of-the-box
- Addition/Subtraction with default(Money) should not throw InvalidCurrencyException HOT 1
- Serializing default Money property in a class (PR#70) HOT 6
- sample code doesn't work
- System.ArgumentOutOfRangeException when printing certain currencies
- Failing Tests - GivenIWantToParseImplicitCurrency HOT 2
- Money.ToString() fails for all currency with NotApplicable (-1) decimal places
- Reduce dependency on CultureInfo.Current and Thread Current culture.
- Why Currency is a struct, not class? HOT 3
- Money constructor with default currency rounds amount HOT 2
- Currency code should be Enum, not a struct HOT 1
- Does NodaMoney run on Mono? What Dependencies are needed?
- Why a dependency on Newtonsoft.Json
- Does not have a strong name
- ExchangeRate how to? HOT 1
- Currency malformed on deserialization HOT 2
- Disable implicit conversion of decimal to money as static configuration option HOT 1
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 nodamoney.