问题描述
这里的工作代码为桌面应用程序创建JSON文件: -
private void GenerateJSONFile(List< Works> WorkList)
{
string jsonString = ;
JsonSerializerSettings J = new JsonSerializerSettings();
J.NullValueHandling = NullValueHandling.Ignore;
J.DefaultValueHandling = DefaultValueHandling.Ignore;
J.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
try
{
jsonString = JsonConvert.SerializeObject(WorkList,Newtonsoft.Json.Formatting.Indented,J);
if (!string.IsNullOrEmpty(jsonString))
{
Common.WriteFile(jsonString,Settings.Default.JSONFilePath,Settings .Default.JSONFilename);
}
}
catch (例外情况)
{
}
}
现在我可以创建JSONP文件。
Do你知道任何解决方案吗?
我尝试过:
私人void GenerateJSONFile(List< works> WorkList)
{
string jsonString =;
JsonSerializerSettings J = new JsonSerializerSettings();
J.NullValueHandling = NullValueHandling.Ignore;
J.DefaultValueHandling = DefaultValueHandling.Ignore;
J.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
尝试
{
jsonString = JsonConvert.SerializeObject(WorkList,Newtonsoft.Json.Formatting.Indented,J);
if (!string.I sNullOrEmpty(jsonString))
{
Common.WriteFile(jsonString,Settings.Default.JSONFilePath,Settings.Default.JSONFilename);
}
}
catch(例外情况)
{
}
}
Here working code Create JSON file for Desktop application :-
private void GenerateJSONFile(List<Works> WorkList) { string jsonString = ""; JsonSerializerSettings J = new JsonSerializerSettings(); J.NullValueHandling = NullValueHandling.Ignore; J.DefaultValueHandling = DefaultValueHandling.Ignore; J.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; try { jsonString = JsonConvert.SerializeObject(WorkList, Newtonsoft.Json.Formatting.Indented, J); if (!string.IsNullOrEmpty(jsonString)) { Common.WriteFile(jsonString,Settings.Default.JSONFilePath, Settings.Default.JSONFilename); } } catch (Exception ex) { } }
Now I can do create JSONP file.
Do you know any solutions?
What I have tried:
private void GenerateJSONFile(List<works> WorkList)
{
string jsonString = "";
JsonSerializerSettings J = new JsonSerializerSettings();
J.NullValueHandling = NullValueHandling.Ignore;
J.DefaultValueHandling = DefaultValueHandling.Ignore;
J.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
try
{
jsonString = JsonConvert.SerializeObject(WorkList, Newtonsoft.Json.Formatting.Indented, J);
if (!string.IsNullOrEmpty(jsonString))
{
Common.WriteFile(jsonString,Settings.Default.JSONFilePath, Settings.Default.JSONFilename);
}
}
catch (Exception ex)
{
}
}
这篇关于如何编写JSONP文件c#.net(桌面应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!