Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / From and to JSON Datatype for my 3D Printer

Author
Message
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 15th Apr 2022 18:12 Edited at: 15th Apr 2022 18:19
So I tried to fill an array with data from an http request to my 3D printer running klipper (if that is of some interest)
The data I Get from the request is already in JSON format so i just tried to use the fromJSON command and got:

then converting the data i got inside my arrayback to JSON i got:

Now if you compare them you can see that the true from the is_active key gets sucessfully converted to a 1 as the Datatype in AppGameKit is an integer for it.
beside that it rounds the floats to the first three digids behind the comma or truncates it if there are only 0's and also creates an empty string value for the message key where originally there is null as the value so the json commands are somewhat smart.
Now Virtual Nomad on Discord suggested to create a tool that automatically creates AppGameKit Datatypes by pasting the complete json file as i asked there how i would construct it.
Here is my AppGameKit code if someone also has a 3D printer running klipper by any chance:
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Apr 2022 21:08
This code will filter the json and convert floats to strings so you can use ValFloat() to get accurate float values.
It returns an array right now so you can see whats happening but it's easy to change it to just a long string
You could fiddle with it to do anything else you wanted.


Login to post a reply

Server time is: 2024-03-29 12:56:43
Your offset time is: 2024-03-29 12:56:43