Click here to Skip to main content
15,886,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all..
how to convert directory structure into json....?
if any body knows pls let me know....
Posted

Hi,

Check this[^]
 
Share this answer
 
Represent directory structure as data structure of your choice and use the class System.Runtime.Serialization.Json.DataContractJsonSerializer. Use appropriate attributes in data type(s), such as DataContract and DataMember, to define a Data Contract. It will help you to store any object graph and restore it back using JSON file/stream for persistent storage. You won't need to program persistence manually in any way which will make your implementation extremely simple and robust.

See:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx[^],
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

Please also see my past answer where I advocate using Data Contracts:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^],
deseralize a json string array[^].

First two of my answers are about System.Runtime.Serialization.Json.DataContractSerializer but are also applicable to System.Runtime.Serialization.Json.DataContractJsonSerializer.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900