Trav Hale

unread,
Jul 25, 2016, 1:45:16 AM7/25/16
to MIT App Inventor Forum
Hello,

I saw some time ago that it was suggested that since the MIT APP system uses JSON in it's framework that it would not be to hard to port that to an extension.
I am curious if this has ever been done, I see lots of posts about formatting your own JSON notation using text, but it would be far easier to do this with an extension (if one existed).

In my scenario I am using a phone to control a panoramic robot through a bluetooth connection, I set the various parameters on the phone and then want to pass this through the bluetooth connection to the arduino as a JSON string which is then parsed on the arduino and fires the respective actions.

I can get the arduino parsing JSON no issues, just have a few issues when it comes to sending the parameters from the MIT app creator device. 

This is the sort of Schema I am working with for the device {"command": "GIGAPAN","version": 1,"timestamp": "YYYY-MM-DD hh:mm:ss","data": [TopX,TopY, BottomX, BottomY, FLength, GPSLat, GPSLng]} where the TopX & Y, Bottom X & Y and FLength values come from listboxes on the MIT app from the phone, and the GPS info comes from the phone / current location as well.

Has anyone got an easier way to encode this schema without manually building the string, or is that really the only way to do this?

The other schema are a fair bit easier, just this one is the one which is a bit of a pain.

Many thanks,

Trav Hale.

Taifun

unread,
Jul 25, 2016, 10:40:00 AM7/25/16
to MIT App Inventor Forum
Has anyone got an easier way to encode this schema without manually building the string, or is that really the only way to do this?
there is currently no easy way

to provide a method to convert a list into JSON format sounds doable
example


in case you are interested to be the sponsor of such a method, please contact me by email.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Abraham Getzler

unread,
Jul 25, 2016, 11:50:08 AM7/25/16
to MIT App Inventor Forum
If you have your data in a pairs list, the blocks aren't too hard for emitting a JSON string.
See attached.
ABG
JSON_encode_pairs.aia
JSON_pairs_to_text.jpg
pairs_to_JSON_to_pairs_to_lookup_value.jpg

Taifun

unread,
Oct 28, 2017, 6:19:05 PM10/28/17
to MIT App Inventor Forum
reopened

Erich Mönch

unread,
Oct 28, 2017, 6:34:44 PM10/28/17
to MIT App Inventor Forum
Thanks Taifun!

For those struggling to create JSON strings from lists, I've created a procedure able to transform multi-level lists into a JSON string ready to be transmitted.

Hope it will help the community. #encode #JSON #list2json




Taifun, if you could explain, I could try to write the method..


List2JSON.aia
List2JSON.jpg

Abraham Getzler

unread,
Oct 28, 2017, 6:52:13 PM10/28/17
to MIT App Inventor Forum
I took a whack at JSON encoding in this Gallery project:

There's some test data in there if you want to give your blocks a workout.

ABG

Erich Mönch

unread,
Oct 28, 2017, 7:15:01 PM10/28/17
to MIT App Inventor Forum
Abraham, yours is fantastic!

Thanks for sharing. I'm finding difficult to search for these already finished solutions...

Taifun

unread,
Oct 28, 2017, 7:47:12 PM10/28/17
to MIT App Inventor Forum
btw. there is also the CSV to Json encode Extension by Andres Daniel 

Taifun
Reply all
Reply to author
Forward
0 new messages