Page 1 of 1

Parsing JSON string with Jxon library

Posted: 17 Mar 2024, 15:07
by JoeWinograd
Hi Folks,

I'm using the Jxon.ahk (Lib function). I understand the AHK assignment statement syntax after calling oJxon:=Jxon_Load(jsonvar). For example, with this JSON data subset...

Code: Select all

{
  "log": {
    "version": "1.1",
    "creator": {
      "name": "HelloWorld",
      "version": "123.45"
    },
    "pages": [
      {
        "timestarted": "2024-03-17T13:15:48",
        "id": "page_3",
        "title": "https://www.test.com"
      }
    ],
...the assignment statments for version and name are:

Code: Select all

LogVersion:=oJxon.log.version
LogCreatorName:=oJxon.log.creator.name
Works great! But I can't figure out how to get the array elements. For example, let's say the Jxon call is oJxon:=Jxon_Load(jsonvar,objBase,arrBase). What is the assignment statement for the timestarted element?

Thanks much, Joe

Re: Parsing JSON string with Jxon library  Topic is solved

Posted: 20 Mar 2024, 12:52
by geek
MsgBox % oJxon.log.pages[1].timestarted or MsgBox % oJxon.log.pages.1.timestarted

Re: Parsing JSON string with Jxon library

Posted: 20 Mar 2024, 13:30
by JoeWinograd
Hi @geek,
Thank you very much! Both methods work perfectly! Regards, Joe