JSON中的目录序列化. [英] Directory serialization in json..

查看:108
本文介绍了JSON中的目录序列化.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

实际上是发生了wat..i,我在"D"中创建了示例文件夹,然后又创建了SAMPLE FOLDER,再次创建了HELLO FOLDER和一个.txt文件,在HELLO FOLDER中,我创建了两个.txt文件. > 在该代码中,我采用默认路径,例如"D:\ sample",上面的整个目录结构都显示为字符串..
字符串是这样的:abc.txt你好xyz.txt pqr.txt ..
现在我想对entrire目录结构进行序列化,并且我想要这样的输出:
{"Root":"d:\\" {"mainfolder":"sample","mfile":"abc.txt","subfolder":"hello" {"hfile1":"xyz.txt","hfile2 :" pqr.txt}}} ..
如果有人知道请让我知道..
在此先感谢..

hi to all..

actuually wat happend means..i create sample folder in ''D'' and in that i created SAMPLE FOLDER ,again i created HELLO FOLDER and one .txt file, in that HELLO FOLDER i created two .txt files..
in that code i take default path like "D:\sample" the above entire directory structure displayed like as a string..
string is like this: abc.txt hello xyz.txt pqr.txt..
now i want to serilaize the entrire directory structure and i want the output like this:
{"Root":"d:\\"{"mainfolder":"sample","mfile":"abc.txt","subfolder":"hello"{"hfile1":"xyz.txt","hfile2":"pqr.txt"}}}..
if any body knows pls let me know..
thanks in advance..

推荐答案

您实际上不需要手动执行任何操作.而是将 Data Contract System.Runtime.Serialization.Json.DataContractJsonSerializer一起使用.

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

另请参阅我过去的解决方案,在此我提倡使用这种强大且易于使用的方法:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [ http://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.datacontractserializer.aspx [
You don''t really need to do anything manually. Instead, use Data Contract with System.Runtime.Serialization.Json.DataContractJsonSerializer.

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

Please also see my past solution where I advocate this robust and easy-to-use approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].

I explain things using System.Runtime.Serialization.Json.DataContractSerializer (http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx[^]), but this is applicable to System.Runtime.Serialization.Json.DataContractJsonSerializer as well.

—SA


查看 fastJSON [ ^ ]用于JSON部分.
然后查看 DirectoryInfo类 [ FileInfo类 [
Check out fastJSON[^] for the JSON part.
And look at DirectoryInfo Class[^] and FileInfo Class[^] for folder and file info.


这篇关于JSON中的目录序列化.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆