Question

To keep track of my new year resolutions I created a file daily.log in the following format.

8:40 AM 1/2/2013

begin:755am
activity:enquired about 3x3 black board;bought book [beginning html 5]
waste:facebook;
meeting:old friend;mechanic
programming:none
blogpost:[asp.net deployment]
do:buy black board
done:
end:1045pm

I am in the process of creating a simple C# console application which would ask me a few questions and fill this file accordingly. One of the future features to this tool would be to display a simple dashboard style web page for measuring the progress of resolutions among other things.

I would to like to use a data serialization or configuration file format for storing daily activity information in this manner, because mature tools are available for these formats rather than for plain text.

I never used JSON before and am wondering whether the JSON format can be used independently with C# (no javascript involved), and even if I can, whether the usage of JSON is appropriate in this case.

If not JSON, its superset YAML? or are any other alternatives that suit well for this purpose?

Était-ce utile?

La solution 2

If your goal is to work with external tools to have them recognize and be able to work with your files, a better bet than JSON would be to use XML. This format is stricter (and you can use XML Schema to validate the format) and there are way more tools that are able to work with XML than there are for JSON.

The .NET Framework also contains extensive support for XML, in the System.Xml namespace (see http://msdn.microsoft.com/en-us/library/system.xml(v=vs.100).aspx).

That being said, there is no reason why JSON would not work with C#. I have personally used the JSON.NET library for most JSON work and it works beautifully (see http://james.newtonking.com/projects/json-net.aspx). Mind you, the data you show in your example is not valid JSON.

Good luck!

Autres conseils

You can use JSON.NET in C# without using javascript. And I believe this data can be modeled in JSON format.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top