nanoframework / json.netmf Goto Github PK
View Code? Open in Web Editor NEWJson Serializer and Deserializer Library for nanoFramework and .NET Micro Framework
License: MIT License
Json Serializer and Deserializer Library for nanoFramework and .NET Micro Framework
License: MIT License
Installed from nuget.
I have tested this code block and get an exception from the extension method DateTimeExtensions.FromIso8601().
#### Exception System.Exception - 0x00000000 (1) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### Json.NETMF.DateTimeExtensions::FromIso8601 [IP: 0083] ####
#### testJSONParse.Program::Main [IP: 0017] ####
Test:
DateTime nowTime = DateTime.Now;
JsonSerializer dataSerializer = new JsonSerializer(DateTimeFormat.ISO8601);
string jsonString = dataSerializer.Serialize(nowTime);
DateTime convertTime = DateTimeExtensions.FromIso8601(jsonString); // exception
Debug.Print("Converted: " + jsonString);
If I attempt to step into the files downloaded from Github I get told the source and nuget files are different, maybe a different issue, but the exception seems to be thrown by the parsing of YEAR which seems to have a leading quote mark. From JSON visualizer the text seems formed correct:
[JSON]: "22/04/2015 10:18:54 PM"
I can't be sure if the date.Split() is incomplete, or if the leading quote isn't working, or if there's some other issue. Any thoughts ?
I would like to be able to say:
FooBar loadedObject = new FooBar();
new JsonSerializer().LoadInto(loadedObject, json);
or
FooBar loadedObject = new JsonSerializer().Load(typeof(FooBar), json);
Is there a plan to add an option to camel-case serialized props?
Hi.
it seems that serialization skips serializing properties whose type is arrays/enumerables of custom objects, since this expression returns true:
(jsonserializer.cs Line 148) (method.ReturnType.IsAbstract)))
Maybe it should be replaced with:
(!method.ReturnType.IsArray && method.ReturnType.IsAbstract)))
Hi.
Dictionary and array serialization is broken due to a wrong initial check on StringBuilder content.
Thanks.
Hi,
just adding such things should fix this:
case "TimeSpan":
{
TimeSpan timeSpan = (TimeSpan)o;
return """ + timeSpan.Days + "d " + timeSpan.Hours + "h " + timeSpan.Minutes + "m "
+ timeSpan.Seconds + "s " + timeSpan.Milliseconds + "m " + """;
}
Json.NetMF was installed via PM (command-line) on NetMF 4.4. There are no dependencies listed for this version of NetMF, so assumed all was good until I tried loading onto target (the special chars in the error statement are as they appear and haven't been modified).
Does anyone have an idea of what might be the missing assembly here? (mscorlib 4.4.0.0 is present)
Assembly: Json.NetMF (1.3.0.0) Attaching deployed file.
Assembly: System.IO (4.4.0.0) Attaching deployed file.
Assembly: AP200NetMFApplication (1.0.0.0) Resolving.
Link failure: some assembly references cannot be resolved!!
Assembly: Json.NetMF (1.3.0.0) needs assembly ' �~��(B����+��' (4.3.1.0)
Assembly: AP200NetMFApplication (1.0.0.0) needs assembly 'Json.NetMF' (1.3.0.0)
Error: a3000000
Waiting for debug commands...
The program '[5] Micro Framework application: Managed' has exited with code 0 (0x0).
If you have a JSON string that has a field that is another object, even if that object is null, DeserializeString() will blow up with an InvalidCast exception.
Expected:
Just "skip" the nested object type and pass it as a string in the parent so it can be parsed further later.
Example:
{"firstName":"John","lastName":"Doe", "Car":{"make":"Ford","model":"F350"}}
The "car" is another object, so when deserializing this, do:
hashTable["firstName"]
hashTable["lastName"]
hashTable["Car"]
Now the result of "firstName" would be "John" but the result of "Car" would be a JSON STRING: {"make":"Ford","model":"F350"}
and then we can deserialize that further manually as needed:
hashTable["make"]
hashTable["model"]
Matt and Matt,
This is so great to see this project being developed further! It's the only JSON utility for NetMF, really. Good work! I'll help where I can. I have some bug fixes from the old IndianaJones project that I will have to see are still present here after some testing, and contribute some fixes if needed. (this nested object situation wasn't among them)
Current version it built against .NET MF 4.3 (RTM) and does not work with .NET MF 4.3 RTM (QFE1). It needs to be recompiled with latest version of framework.
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.