Problem inserting json data

I’m using the JsonTools extension (http://thunkableblocks.blogspot.com/2017/07/jsontools-extension.html) to read some very simplle json data:

{“height”:1.15,“direction”:1,“test”:“teste123”}

I’m trying to populate a text field with the value of “test” (or “height”), but unable to get any data.

Here’s my Thunkable block:

blocks%20(4)

This sets the value of the text field to the raw JSON data, so I know I’m receiving the data properly, just not parsing it.

blocks%20(5)

Same results with this simplified block:

blocks%20(6)

And this too:

blocks%20(8)

I don’t imagine anyone sees what I might be doing wrong?

I wonder if @LukeGackle might have some idea about what I’m doing wrong…

Hi @wrybread,

Your last example demonstrates the correct way to use the extension where you pass the input first and then call the json tools functions to get your data.

A couple things to check:

Ensure that you are using version 4 of JSONTools Extension

If you are using different quotes (may be formatting of Thunkable site), change quotes (“”) to standard quotes (")

Thanks for that. Confirmed using version 4. Looks like the problem is on my end though. For some reason with the following block:

blocks%20(9)

The text is appearing in the text2 text field as:

({"height":3.65,"dire)

That’s an odd one. It should be:

{“height”:3.65,“direction”:1,“test”:“teste123”}

(Which isn’t just longer, but isn’t surrounded by parentheses).

Does anyone happen to have some theory? Is it possible that the BluetoothLE1 is truncating the data?

Here’s my BLE services. Could this be a factor?

blocks%20(10)

blocks%20(11)

blocks%20(12)

Aha, looks like BLE only allows transfers up to 20 bytes without jumping through some hoops:

Argh.

Here’s an odd one. My Arduino is now sending the following string via BLE for testing:

3.65,1,55

But when I run these blocks:

blocks%20(13)

It’s being printed to the text field “text2” as:

(3.65,1,55)

(Note the parenthesis). Which makes me think it’s a list? Can anyone confirm whether it’s a list or not? Can I test for data types in Thunkable?

When I run the Android app nRF Connect and connect to my Arduino and echo the data it receives it doesn’t have the parenthesis, so I think that’s added by Thunkable.

Here’s a workaround that works, but it isn’t exactly pretty. Note that I’m having to do a string replace to remove the ( character, which is odd. Then I’m splitting the data into a list by the comma character. Another workaround would be to include a leading comma and trailing comma in the bluetooth data string (and discard that first and last index after splitting the data).

I think a really nice feature for Thunkable would be if we could have blocks of regular code… Especially for string processing. But oh well, this works too.

blocks%20(14)

blocks%20(15)

blocks%20(16)