Hi all!
I’m trying JSON parsing for the first time and getting stuck. I’ve tried to do what Rick Araujo demonstrated in his reply to this post Understanding JSON but my JSON file has one less layer in it than his example. It’s less complex, but I’m stuck.
I need to get the post fields and make use of some of them.
My code so far is:
//json file is stored as string jsonTextString
var js as new JSONItem(jsonTextString)
var messages, data, postElements as JSONItem
messages = js.Value("messages")
var lastMessage as Integer = messages.LastRowIndex
for messageIndex as Integer = 0 to lastMessage
data = messages(messageIndex)
//here's where I get stuck
next
My JSON file is this:
{
"type": "saved_messages",
"id": 4747372822,
"messages": [
{
"id": 161,
"type": "service",
"date": "2025-05-27T20:00:51",
"date_unixtime": "1748401251",
"actor": "John Smith",
"actor_id": "user4747372822",
"action": "clear_history",
"text": "",
"text_entities": []
},
{
"id": 165,
"type": "message",
"date": "2025-05-27T20:25:31",
"date_unixtime": "1748402731",
"from": "John Smith",
"from_id": "user4747372822",
"forwarded_from": "Trade Watcher",
"saved_from": "Trade Watcher",
"photo": "photos/photo_1@27-05-2025_20-25-31.jpg",
"photo_file_size": 83046,
"width": 1179,
"height": 671,
"text": [
{
"type": "bold",
"text": "BREAKING: President Trump says Putin is “playing with fire.”"
},
""
],
"text_entities": [
{
"type": "bold",
"text": "BREAKING: President Trump says Putin is “playing with fire.”"
},
{
"type": "plain",
"text": ""
}
]
},
{
"id": 166,
"type": "message",
"date": "2025-05-27T20:25:31",
"date_unixtime": "1748402731",
"from": "John Smith",
"from_id": "user4747372822",
"forwarded_from": "Trade Watcher",
"saved_from": "Trade Watcher",
"photo": "photos/photo_2@27-05-2025_20-25-31.jpg",
"photo_file_size": 79738,
"width": 1200,
"height": 676,
"text": [
{
"type": "bold",
"text": "Traders bet on Nvidia surge ahead of earnings"
},
"\n\nBullish sentiment builds as call options stack up around $145–$150 strikes, with ",
{
"type": "cashtag",
"text": "$NVDA"
},
" closing at $131.29 on Friday.\n\nA $5.5B China-related charge may hit Q1, but traders are eyeing a potential 6.7% move — Nvidia rarely stays quiet on earnings."
],
"text_entities": [
{
"type": "bold",
"text": "Traders bet on Nvidia surge ahead of earnings"
},
{
"type": "plain",
"text": "\n\nBullish sentiment builds as call options stack up around $145–$150 strikes, with "
},
{
"type": "cashtag",
"text": "$NVDA"
},
{
"type": "plain",
"text": " closing at $131.29 on Friday.\n\nA $5.5B China-related charge may hit Q1, but traders are eyeing a potential 6.7% move — Nvidia rarely stays quiet on earnings."
}
]
},
{
"id": 167,
"type": "message",
"date": "2025-05-27T20:25:31",
"date_unixtime": "1748402731",
"from": "John Smith",
"from_id": "user4747372822",
"forwarded_from": "Trade Watcher",
"saved_from": "Trade Watcher",
"photo": "photos/photo_3@27-05-2025_20-25-31.jpg",
"photo_file_size": 34855,
"width": 751,
"height": 736,
"text": [
{
"type": "bold",
"text": "$7.24T parked in money markets — record high"
},
"\n\nTotal assets in Money Market Funds have surged to an all-time high of $7.24 trillion. \n\nThis reflects growing investor caution and a strong preference for yield and liquidity amid market uncertainty."
],
"text_entities": [
{
"type": "bold",
"text": "$7.24T parked in money markets — record high"
},
{
"type": "plain",
"text": "\n\nTotal assets in Money Market Funds have surged to an all-time high of $7.24 trillion. \n\nThis reflects growing investor caution and a strong preference for yield and liquidity amid market uncertainty."
}
]
}
]
}