我试图在powershell中操作json文件数据并将其写回文件.甚至在操作之前,当我刚刚从文件中读取时,将它转换为powershell中的Json对象并将其写回文件,某些字符将被某些代码替换.以下是我的代码:
$jsonFileData = Get-Content $jsonFileLocation
$jsonObject = $jsonFileData | ConvertFrom-Json
... (Modify jsonObject) # Commented out this code to write back the same object
$jsonFileDataToWrite = $jsonObject | ConvertTo-Json
$jsonFileDataToWrite | Out-File $jsonFileLocation
Run Code Online (Sandbox Code Playgroud)
某些字符正在被其代码替换.例如:
< is replaced by \u003c
> is replaced by \u003e.
' is replaced by \u0027
Run Code Online (Sandbox Code Playgroud)
样本输入:
{
"$schema": "https://source.com/template.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"accountName": {
"type": "string",
"defaultValue": "<sampleAccountName>"
},
"accountType": {
"type": "string",
"defaultValue": "<sampleAccountType>"
},
},
"variables": {
"location": "sampleLocation",
"account": "[parameters('accountName')]",
"type": "[parameters('accountType')]", …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 SAS url 位置复制到目标存储帐户。我尝试了以下命令,但几乎没有错误:
AzCopy.exe /来源:http : //www.blob.core.windows.net/vhd1/? sv=2014-02-14&sr=c&sig=xxxxxxxxxxxxxxxxx&st=2015-08-05T04%3A00%3A00Z&se=2015-049-0 %3A00%3A00Z&sp=rl /Dest: https://yyyyyyyy.blob.core.windows.net/vhds /Destkey:zzzzzzzzzzzzzzzzzzz filename1.vhd /Y
命令的语法不正确。参数“源”中的 SAS 标记无效。'sr' 不是内部或外部命令,也不是可运行的程序或批处理文件。'sig' 不是内部或外部命令,也不是可运行的程序或批处理文件。'st' 不是内部或外部命令,也不是可运行的程序或批处理文件。'se' 不是内部或外部命令,也不是可运行的程序或批处理文件。'sp' 不是内部或外部命令,也不是可运行的程序或批处理文件。
AzCopy.exe /Source: http://wwwwwwww.blob.core.windows.net/vhd1 /Dest: https://xxxxxxxxxx.blob.core.windows.net/vhds /SourceSAS:?sv=2014-02-14&sr =c&sig=yyyyyyyyyy&sp=rl /Destkey:zzzzzzzzz filename1.vhd /Y
命令的语法不正确。参数“SourceSAS”中的 SAS 标记无效。'sr' 不是内部或外部命令,也不是可运行的程序或批处理文件。'sig' 不是内部或外部命令,也不是可运行的程序或批处理文件。'st' 不是内部或外部命令,也不是可运行的程序或批处理文件。'se' 不是内部或外部命令,也不是可运行的程序或批处理文件。'sp' 不是内部或外部命令,也不是可运行的程序或批处理文件。
我想知道这些错误的原因可能是什么。
谢谢
我需要在文件夹中获取所有文件扩展名类型.例如,如果目录的ls给出以下内容:
a.t
b.t.pg
c.bin
d.bin
e.old
f.txt
g.txt
Run Code Online (Sandbox Code Playgroud)
我应该通过运行脚本来实现这一点
.t
.t.pg
.bin
.old
.txt
Run Code Online (Sandbox Code Playgroud)
我有一个bash shell.
非常感谢!
我想通过powershell在现有存储帐户中创建一个azure存储容器.我尝试了以下命令:
Set-AzureSubscription -CurrentStorageAccountName "storageaccountv1" -SubscriptionId $SubscriptionId
New-AzureStorageContainer -Name $ContainerName -Permission Off
Run Code Online (Sandbox Code Playgroud)
对于那些知道的人,Azure有两种类型的存储帐户:v1,v2.V1帐户是都可以通过的那些http://manage.windowsazure.com/可以在创建和v2 http://portal.azure.com/.虽然命令New-AzureStorageContainer正在使用v1中的存储帐户,但该命令不适用于v2中的存储帐户.它给出以下错误:
New-AzureStorageContainer : ResourceNotFound: The storage account 'storageaccountv2' was not found.
At CreateStorageContainer.ps1:31 char:1
+ New-AzureStorageContainer -Name $ContainerName -Permission Off
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureStorageContainer], CloudException
+ FullyQualifiedErrorId : CloudException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.NewAzureStorageContainerCommand
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉如何通过powershell在v2中创建一个azure存储容器?
我想将列表转换为地图,其中键只是一个计数器,它需要遵守列表的顺序。我目前有这个代码:
private static Map<String, String> convertListToMap(final List<String> list) {
AtomicInteger counter = new AtomicInteger(0);
Map<String, String> map = list.stream().collect(Collectors.toMap((c) -> {
Integer integer = counter.incrementAndGet();
return integer.toString();
}, (c) -> c));
return map;
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
#include在.h文件中和在.c文件中执行a有什么区别?
例如,我有一个文件a.h,a.c其中有一个class A。我使用class A的class B(b.h,b.c)。做一个include之间有什么区别:
#include "a.h"
Run Code Online (Sandbox Code Playgroud)
在b.hVS b.c?
我是C#和IEnumerable的新手。我想替换IEnumerable中的特定项目。例如
IEnumerable<string> m_oEnum = new string[] {"abc","def","ghi", "abcdef"};
Run Code Online (Sandbox Code Playgroud)
我只想将字符串“ abc”替换为“ abc-test”,但不更改“ abcdef”。
在C#中,我有一个类:
public class Person
{
public string name;
public int id;
}
Run Code Online (Sandbox Code Playgroud)
目前,当我这样做时:
Person person = new Person
{
name = "John",
id = 3
}
// Will be converted Console.Writeline("Person = " + person.ToString()); by the compiler
Console.Writeline("Person = " + person);
Run Code Online (Sandbox Code Playgroud)
我可以在类中做什么来使从人到人的自动转换无效.ToString()并使编译器给出一个错误来指示Person对象不能隐式转换为字符串?
c# ×2
powershell ×2
azcopy ×1
azure ×1
bash ×1
c++ ×1
file ×1
hashmap ×1
header ×1
ienumerable ×1
include ×1
java ×1
java-stream ×1
json ×1
list ×1
readfile ×1
replace ×1
search ×1
signatures ×1
tostring ×1
writetofile ×1