Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:58 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Webmite Manual v3 - JSON$ function

Author Message
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 06:27pm 30 Aug 2023
Copy link to clipboard 
Print this post

Hi there

It would appear that the JSON$ function is not present in the Function table of the manual, but is referenced on Pages 30 and 121.

On Page 120 the WATCHDOG entry appears to be duplicated.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
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
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024