How can i encode and display csv, json in text format (extension)

How do i encode and display csv or json to text format? i need it for to make an extension

please inform me to make question more clear

1 Like

You can just ask your question. All the extra is not necessary.

2 Likes

oh i see i now fixed it

but i still need the solution

You may use org.json library or use JsonUtil class to decode Json.

org.json library documentation : org.json | Android Developers

JsonUtil class : appinventor-sources/JsonUtil.java at master · mit-cml/appinventor-sources (github.com)


As well you may use CsvUtil class from appinventor to decode csv.

CsvUtil class : appinventor-sources/CsvUtil.java at master · mit-cml/appinventor-sources (github.com)

An example can be :

public Object  ListFromCsvTable(String csvString){
    try{
        return CsvUtil.fromCsvTable(csvString); // It will return YailList
    }catch(Exception e){
        // You can call any event like OnError event-method
        return "";
    }
}

public Object JsonToDictionaries(String jsonString){
    try{
        return JsonUtil.getObjectFromJson(jsonString, true);
    }catch(Exception e){
        // call any event like OnError 
       return "";
    }
}
3 Likes

but the csvstring is the spreadsheet id right?

What do you mean spreadsheet id ? What spreadsheet ?

2 Likes

for example if i have a google sheet then i will need its spreadsheet id to return the value so it will need that right?

in the CsvString param

No, You should pass a csv string not the spreadsheet id.

1 Like

do you even know what csv is? its not a spreadsheet database but in a way it is something is local version of it like excel.

if you want to use spreadsheet then -

3 Likes

yes i know what is it

then how does'CsvString' work?

it stands for comma separated values (you can guess some things by the name)

for more info -

2 Likes

i know it so 'csvstring' is like 'test1, test2, test3' and so on?

i am not sure what you are saying
but like -

Year,Make,Model,Description,Price
1997,Ford,E350,"ac, abs, moon",3000.00
1999,Chevy,"Venture ""Extended Edition""","",4900.00
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
1996,Jeep,Grand Cherokee,"MUST SELL!
air, moon roof, loaded",4799.00

an example

2 Likes

Yes this one

so what do you wanna do? you have to show this table?

1 Like

Yes I want to show

i think for that you will have to parse and use dynamic component to generate a table

2 Likes