Posted: 08:22pm 30 Aug 2023 |
Copy link to clipboard |
Print this post |
|
Possibly this might help someone...
'JSON String Parsing Example '----------------------------- 'JSON string format {"variable name1":"data string1","variable name2":"data string2", etc} 'In order to capture this in a piece of code we need the \q to replace the " see WebMite Manual Pg 35&36 'The command parses the LongString%() target for the "phrase" and returns the value after the : 'JSON$(LongString%(),"phrase") 'In demonstration consider the following ' OPTION ESCAPE 'Allows certain ASCII characters to be embedded in strings through the use of \
PlayArea
Sub PlayArea Local JSONString%(64/8) 'Dimension Integer Longstring JSON1$="{\qa\q:99,\qb\q:0,\qc\q:45,\qd\q:\qcheese\q,\qe\q:\qspread\q}" 'Create JSON string as a normal string LongString Append JSONString%(),JSON1$ 'Append the normal string to the declared LongString For i= 97 To 101 'ASCII 97 is a and ASCII 101 is e, effectively looping from a to e, the variable names Print Json$(JsonString%(),Chr$(i));" "; 'Chr$(i) resolves to the string a through e in the For Loop Next i End Sub
Terminal Output 99 0 45 cheese spread
Cheers Carl Retirement is tough on Hobbies without a day job |