Comments (2)
Hi,
So I reviewed this some more and did some testing, and the code is actually behaving correctly per the JSON spec. When you serialize a DateTime into a JSON string, it must be in a string enclosed in escaped double-quotes. So, your example became ""2015-04-22T22:18:54.000Z"". This is a correctly formatted DateTime in JSON. The datetime conversion utility method is expecting a normal date-time string, not formatted in JSON. So it needs just: "2015-04-22T22:18:54.000Z". In order to achieve this in your code snippet you need to deserialize the serialized object so you need to add a line of code.
DateTime nowTime = DateTime.Now;
JsonSerializer dataSerializer = new JsonSerializer(DateTimeFormat.ISO8601);
string jsonString = dataSerializer.Serialize(nowTime);
string deserializedJsonString = (string)dataSerializer.Deserialize(jsonString);
DateTime convertTime = DateTimeExtensions.FromIso8601(deserializedJsonString);
Debug.Print("Converted: " + jsonString);
from json.netmf.
Awesome - the example deserializes into the hashtable, which is the difference that my scenario didn't, and the relevance of that didn't strike me. The interesting thing is that VS's JSON visualizer handled it fine when looking at the local variable, so it must cater for stripping the quotes.
I am hitting another issue but think this one will be harder to figure out - still working through it and will report back separately if I think there's something you can do. I am sending JSON objects over a 2.4ghz wireless link and when I get transmission issues, I always end up with data inconsistencies. which can lead to repeated keys that probably don't get hashtabled too well :)
from json.netmf.
Related Issues (9)
- Array serialization issue HOT 1
- Json.NetMF 1.3.0.0 installed successfully, but complains of missing some assembly when loading HOT 6
- Nested objects cause InvalidCast exception HOT 1
- Starting "," in object serialization HOT 1
- Add support for .NET MF 4.3 RTM (QFE1) HOT 1
- camel casing props HOT 2
- Is there a plan to add a "load into an object" feature? HOT 1
- JsonSerializer ignore value for TimeSpan objects 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 json.netmf.