0
API로 요청을 보내고 JSON 형식으로 응답하는 매크로를 완료했습니다. 결과는 Sheet ("results")로 반환됩니다. 나는 또한 별도의 로그 파일을 만들고있다.VBA JSON 로그인 TXT ""
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
그러나 따옴표 "엑셀이 필요"가 않습니다 :
: (비트 잘린가) 같은"{
""title"": ""Example Schema"",
""type"": ""object"",
""properties"": {
""firstName"": {
""type"": ""string""
},
""lastName"": {
""type"": ""string""
},
""age"": {
""description"": ""Age in years"",
""type"": ""integer"",
""minimum"": 0
}
},
""required"": [""firstName"", ""lastName""]
}"
내 매크로 외모 문제는 출력이 같은 표준 JSON 형식으로되지 않는 것입니다
'output path
Dim FF As Integer
FF = FreeFile
Dim FilePath As String
FilePath = ActiveWorkbook.Path & "\Log" & Format(Now(), "yyyymmdd") & ".txt"
Open FilePath For Append As FF
sJson = ""
'turncated here ...
ObjHttp.Open "POST", sURL, False
ObjHttp.setRequestHeader "Content-Type", "application/json"
ObjHttp.send (sJson)
xmlDoc.LoadXML (ObjHttp.responseText)
'log
Dim LastRow As Long
With ThisWorkbook.Sheets("Result")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Sheets("Result").Cells(LastRow + 1, 1) = Now()
Sheets("Result").Cells(LastRow + 1, 2) = ObjHttp.responseText
Write #FF, ObjHttp.responseText
Next i
Close #FF
End Sub
큰 따옴표를 제거하려면 무엇을 변경해야합니까?
미리 감사드립니다.
이 찾아 따옴표를 그을음 큰 따옴표 표시를 대체합니다 ['교체()'기능 (http://msdn.microsoft.com/en-us/library/gg264409 (V = office.14) .aspx) –
Write 할 때 #FF, Replace (ObjHttp.responseText, Chr (34), "") 이것은 텍스트에서 모든 따옴표를 완전히 제거합니다 ... #FF를 쓰려고하면 Replace (ObjHttp.responseText, Chr (34) & Chr (34), Chr (34)) 아무 것도하지 않습니다 ... – Petrik
'Write' 대신'Print #FF, ObjHttp.responseText'를 사용하십시오. –