我想用JSON-Builder创建一个数组.
预期格式:
{
"Header": {
"SomeKey" : "SomeValue"
}
"Data": [
{
"SomeKey" : "SomeValue"
},
{
"SomeKey" : "SomeValue"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的代码:
def builder = new groovy.json.JsonBuilder()
def root = builder {
Header {
"Typ" "update"
"Code" "UTF-8"
"TransaktionsNr" item.transactionNumber
"DatumZeit" new Date().format("dd.MM.yyyy HH:mm")
}
customers.each ({ customer->
"Data" {
"Email" customer.code
"Newsletter" customer.newsletterSubscribed
}
})
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我只在数据部分得到一个元素.我尝试使用[]而不是{},但我仍然只得到一个元素,我做错了什么?
我想遍历一个字符串,我想在这个索引处同时拥有索引和字符。我知道我可以为此使用一个简单的 for 循环,但我认为 Javascript/Typescript 的一些新功能可能更优雅,所以我尝试了这个:
for (const [i, character] of Object.entries('Hello Stackoverflow')) {
console.log(i);
console.log(typeof(i));
console.log(character);
}
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是,这有效,但是即使i计数,它也是一个字符串。因此,例如这不起作用:
'other string'.charAt(i)
Run Code Online (Sandbox Code Playgroud)
我是 Typescript 的新手,所以我的问题是:
我alyways使用git bash,但现在我必须改为cygwin,因为我需要wget和其他东西,所以我认为我可以使用内置git,因为它更新.
git bash是版本1.9.4-preview,cygwin中的版本是2.1.4版本.我有一个使用git bash工作的克隆回购.我承诺推动一切,我在开发分支.当我使用"git status"时,我得到了这个:
On branch develop
Your branch is up-to-date with 'origin/develop'.
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
在cygwin中,我得到了这一部分
On branch develop
Your branch is up-to-date with 'origin/develop'.
Run Code Online (Sandbox Code Playgroud)
但后来我得到了数百个未提交的文件列表.为什么我会得到不同的结果?我在同一个仓库中的同一个目录中,结果应该是一样的.