我正在使用cloud9在线IDE开发node.js应用程序.我需要编辑.gitignore文件,但我看不到它,因为它是一个隐藏文件.有谁知道如何在cloud9文件树中显示隐藏文件?
我正在尝试将一些 JSON 转换为 XML,但在此之前我需要更改一些属性才能成功转换。
JSON 结构中的某些属性以数字开头,当我尝试转换为 XML 时,我收到错误消息,因为 XML 不允许以数字开头的标签。
因此,对我有用的一种解决方案是通过向属性添加前缀来更改以数字开头的属性名称。
我一直在尝试做这样的事情:
public string ChangeNumericalPropertyNames(JsonReader reader)
{
JObject jo = JObject.Load(reader);
foreach (JProperty jp in jo.Properties())
{
if (Regex.IsMatch(jp.Name, @"^\d"))
{
string name = "n" + jp.Name;
//Logic to set changed name
}
}
return "Here I want to return the entire json string with changed names";
}
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时:
jp.Name = name;
Run Code Online (Sandbox Code Playgroud)
Visual Studio 说这是不可能的,因为它jp.Name是只读的。
有人知道如何实现这个解决方案吗?
我正在处理Visual Studio C#项目,我需要将 a 转换JSON为XML. 我收到JSON字符串格式的。问题是,JSON如果JSON没有根节点,我需要在结构中有一个根节点,以便我可以转换为XML所需的格式。
假设我有这个JSON:
{
"id": 1,
"name": {
"first": "Yong",
"last": "Mook Kim"
},
"contact": [{
"type": "phone/home",
"ref": "111-111-1234"
}, {
"type": "phone/work",
"ref": "222-222-2222"
}]
}
Run Code Online (Sandbox Code Playgroud)
我想像这样添加根节点JSON:
{
"user": {
"id": 1,
"name": {
"first": "Yong",
"last": "Mook Kim"
},
"contact": [{
"type": "phone/home",
"ref": "111-111-1234"
}, {
"type": "phone/work",
"ref": "222-222-2222"
}]
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能用 …