Write to a Json file

189 views
Skip to first unread message

Sunny Afternoons

unread,
Jun 12, 2016, 7:38:42 AM6/12/16
to MIT App Inventor Forum
Hello, im trying to write a new node to a Json file placed on Dropbox but it dont work. if i made same in windows with notepad, it work. Here is my captured screens. What im doing wrong? Thanks.






Taifun

unread,
Jun 12, 2016, 10:40:39 AM6/12/16
to MIT App Inventor Forum

How to upload a file into your Dropbox

see also here http://stackoverflow.com/a/37262976/1545993 how to use external inputs to avoid long nested calculation blocks
Taifun

Sunny Afternoons

unread,
Jun 12, 2016, 11:49:22 AM6/12/16
to MIT App Inventor Forum
ok thanks but your example dont add a node. Only upload a file to dropbox.

I need to add a node and update the file and i dont know how. Mi code dont work.

Thanks.



Taifun

unread,
Jun 12, 2016, 12:19:24 PM6/12/16
to MIT App Inventor Forum
ok thanks but your example dont add a node. Only upload a file to dropbox.
that's correct
I think, you have to 1. download the file, 2. add the node, 3. upload the file again
unfortunately I do not have an example for 1 and 2 currently
for 1. if you have a public link to the file, then you should be able to download it like this https://puravidaapps.com/filedownload.php
for 2. see again ABG's tips in your other thread https://groups.google.com/d/msg/mitappinventortest/Q6qY79cepY8/IASJT4_fDAAJ

Taifun

Sunny Afternoons

unread,
Jun 12, 2016, 1:12:32 PM6/12/16
to MIT App Inventor Forum
Yes, i have a public link but i dont know how to add a node. I do not have any example.

Taifun

unread,
Jun 12, 2016, 1:21:16 PM6/12/16
to MIT App Inventor Forum
ABG gave you a nice procedure to encode JSON here https://groups.google.com/d/msg/mitappinventortest/Q6qY79cepY8/IASJT4_fDAAJ
it looks like you did not even take a look at it or play around with it?

see also tip 2 here

and

now try something and if you get stuck, post a screenshot of your relevant blocks including Do it results

Taifun

Sunny Afternoons

unread,
Jun 12, 2016, 1:38:44 PM6/12/16
to MIT App Inventor Forum
I see tip 2.

My resultant blocks of your help are this. Nothing has happend. Im lost, very lost. 




Taifun

unread,
Jun 12, 2016, 2:00:34 PM6/12/16
to mitappinv...@googlegroups.com
My resultant blocks of your help are this. Nothing has happend
these are the blocks for uploading a file

if you want help about how to add a node into your JSON text, then I suggest you to post the relevant blocks including Do it results
you should be familiar with working with lists and list of lists, see the links form my previous answer

it probably helps to follow these steps
1. use Do it to display the JSON before adding the node
2. convert the JSON format into a list of lists using the JsonTextDecode block from the Web component (again use Do it)
3. find the position where exactly you like to add the node (wich is a list) (again use Do it)
4. use the insert list item block to add the node  (i.e. the list) at the desired position (again use Do it)
5. use Do it again to display the list of lists after adding the node
6. use ABG's procedure to encode the list of lists into JSON format (again use Do it)

how to use Do it, see tip 4 here
Taifun

Sunny Afternoons

unread,
Jun 14, 2016, 5:53:26 AM6/14/16
to MIT App Inventor Forum
Thank you for your help.

I followed the advices of Taifun and I have done the following:

I downloaded the json file from dropbox.

I read the text file into a variable with a function Taifun in puravidaapps (parse).

I added a node manually

I've saved the file.

I have uploaded to dropbox and perfectly replaces the existing one.

With another app, I tried to read the updated file and reads it perfectly.

Thank you for your help.

I leave the screenshots I've used for this example I have to adapt now and texboxes variables.



Reply all
Reply to author
Forward
0 new messages