Мне действительно нужно извлечь элементы "предложение" и "текст" из ответа json, прилагаемого ниже. Я пытался использовать JsonConverter от Tim Hall, но я получаю ошибку «Type: Mismatch».
Вот основная часть моего кода для вашего обзора:
body = Worksheets("Open1").Range("A2").Value 'Json data in a cell
xmlhttp.Open "POST", Url, False, authUsername, authPassword
xmlhttp.SetRequestHeader "Content-Type", "application/json"
'xmlhttp.SetRequestHeader "Authorization", "Basic " & EncodeBase64(workspaceID)
xmlhttp.Send body
If xmlhttp.Status = 200 Then 'Request success
response = xmlhttp.ResponseText
Set json = JsonConverter.ParseJson(response)
Debug.Print response
Else 'Request fail
И здесь ответ json, из которого я хочу извлечь элементы «предложение» и «текст» из
{
"usage": {
"text_units": 1,
"text_characters": 386,
"features": 1
},
"semantic_roles": [
{
"subject": {
"text": "I"
},
"sentence": "I'm looking for someone to help us long-term in analyzing client data to consolidate data into a meaningful and understandable way to identify trends and append various information.",
"object": {
"text": "for someone to help us long-term in analyzing client data to consolidate data into a meaningful and understandable way to identify trends and append various information"
},
"action": {
"verb": {
"text": "look",
"tense": "present"
},
"text": "looking",
"normalized": "look"
}
},
{
"subject": {
"text": "someone"
},
"sentence": "I'm looking for someone to help us long-term in analyzing client data to consolidate data into a meaningful and understandable way to identify trends and append various information.",
"object": {
"text": "client data"
},
"action": {
"verb": {
"text": "analyze",
"tense": "present"
},
"text": "analyzing",
"normalized": "analyze"
}
},
{
"subject": {
"text": "someone"
},
"sentence": "I'm looking for someone to help us long-term in analyzing client data to consolidate data into a meaningful and understandable way to identify trends and append various information.",
"object": {
"text": "data"
},
"action": {
"verb": {
"text": "consolidate",
"tense": "future"
},
"text": "to consolidate",
"normalized": "to consolidate"
}
},
{
"subject": {
"text": "someone"
},
"sentence": "I'm looking for someone to help us long-term in analyzing client data to consolidate data into a meaningful and understandable way to identify trends and append various information.",
"object": {
"text": "trends"
},
"action": {
"verb": {
"text": "identify",
"tense": "future"
},
"text": "to identify",
"normalized": "to identify"
}
},
{
"subject": {
"text": "data dumps of sales reports that we need to take and match and understand which products, product categories are selling the most"
},
"sentence": " Typical work includes data dumps of sales reports that we need to take and match and understand which products, product categories are selling the most.",
"object": {
"text": "Typical work"
},
"action": {
"verb": {
"text": "include",
"tense": "present"
},
"text": "includes",
"normalized": "include"
}
},
{
"subject": {
"text": "we"
},
"sentence": " Typical work includes data dumps of sales reports that we need to take and match and understand which products, product categories are selling the most.",
"object": {
"text": "which products, product categories"
},
"action": {
"verb": {
"text": "understand",
"tense": "present"
},
"text": "match and understand",
"normalized": "match and understand"
}
},
{
"subject": {
"text": "product categories"
},
"sentence": " Typical work includes data dumps of sales reports that we need to take and match and understand which products, product categories are selling the most.",
"object": {
"text": "selling"
},
"action": {
"verb": {
"text": "be",
"tense": "present"
},
"text": "are",
"normalized": "be"
}
},
{
"subject": {
"text": "they"
},
"sentence": " How they compare month over month.",
"object": {
"text": "month"
},
"action": {
"verb": {
"text": "compare",
"tense": "present"
},
"text": "compare",
"normalized": "compare"
}
}
],
"language": "en"
}