我正在通过JavaScript为AJAX请求提供JSON响应.
以下是回复:
{"responseCode":400,"errors":false,"submitted":false,"content":"some content","notice":""}
Run Code Online (Sandbox Code Playgroud)
我的目标是获取内容:
"some content"
Run Code Online (Sandbox Code Playgroud)
json变量就是我的数据.所以,我尝试过:
data.content
Run Code Online (Sandbox Code Playgroud)
但我正在设置一个空字符串.
有关如何访问字符串的任何想法?
先感谢您.
所以我试图检查路径是否可用。我用测试路径做这个
它看起来像这样:
$c="C:\"
$d="D:\"
$e="E:\"
if(Test-Path $c -eq "False"){
}
elseif(Test-Path $d -eq "False"){
}
elseif(Test-Path $e -eq "False"){
}
else{
"The File doesn't exist"
}
Run Code Online (Sandbox Code Playgroud)
那么如果错误看起来像这样,我做错了什么:
Test-Path : A parameter cannot be found that matches parameter name 'eq'.
At C:\Users\boriv\Desktop\ps\Unbenannt1.ps1:23 char:17
+ If(Test-Path $c -eq "False"){
+ ~~~
+ CategoryInfo : InvalidArgument: (:) [Test-Path], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.TestPathCommand`
Run Code Online (Sandbox Code Playgroud) 所以我正在用Powershell做一个robocopy.我只想写一个日志文件.Robocopy工作,但尝试和捕获不起作用.这是我的Powershell代码:
function Write-Log{[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[ValidateSet("INFO","WARN","ERROR","FATAL","DEBUG")]
[String]
$level = "INFO",
[Parameter(Mandatory=$True)]
[string]
$message ,
[Parameter(Mandatory=$True)]
[string]
$logfile
)
$timeStamp = (Get-Date).toString("dd.MM.yyyy HH:mm:ss")
$line = "$timeStamp $level $message"
if($logfile) {
Add-Content $logfile -Value $line
} else {
Write-Output $line
}}
try {C:\WINDOWS\SysWOW64\robocopy.exe "C:\Users\boriv\Desktop\por" "C:/users/boriv/desktop/1" robocopy *.* /MIR /EFSRAW /DCOPY:DAT /A+:R /A-:AE /IA:ACEHNORST /V /BYTES}
catch { Write-Log -message "Der Kopiervorgang war nicht erfolgreich" -logfile "C:\users\boriv\Desktop\$(get-date -f dd-MM-yyyy).txt" -level ERROR}
Write-Log -message "Der Kopiervorgang war erfolgreich" -logfile "C:\users\boriv\Desktop\$(get-date -f dd-MM-yyyy).txt" -level INFO
Run Code Online (Sandbox Code Playgroud)