Chars exchanges. Dictionary. Json to csv. Transliteration

Hello friends,

here are some examples of character swapping.

cambio_chars.aia (14.4 KB)

In this study we will find enfants terribles, these are characters that do not want to be with their companions in string or in dictionaries.


we will also find different forms of quotation marks:

1.- In the first example we will swap these characters:


we will use pairs list created from a string:

a,z\nb,y\nc,x\nd,w\ne,v\nf,u\ng,t\nh,s\ni,r\nj,q\nk,p\nl,o\nm,n\nn,m\no,l\np,k\nq,j\nr,i\ns,h\nt,g\nu,f\nv,e\nw,d\nx,c\ny,b\nz,a\n

Here we find an enfant terrible: the space, we cannot insert the space in the string to work with the list, so we will insert the space in the list of pairs using the block: add items to list

3 Likes

2.- JSON TO CSV

In a post I found this text “json” that a user wanted to pass it csv, it is a badly formatted json

{“1”: {“city”: “” city1 \ “”, “name”: “” name1 \ “”}, “2”: {“city”: “” city2 \ “”, "name “:” \ "name2 " “}, ” 3 “: {” city “:” \ "City3 " “,” name “:” \ "name3 " “}, ” 4 “: {” city ": “” city4 \ “”, “name”: “” name4 \ “”}, “5”: {“city”: “” City5 \ “”, “name”: “” name5 \ “”}, “6”: {“city”: “” City6 \ “”, “name”: “” name6 \ “”}, “7”: {“city”: “” City7 \ “”, "name “:” \ "name7 " “},” 8 “: {” city “:” \ "City8 " “,” name “:” \ “name8” “},” 9 “: {” city ": “” City9 \ “”, “name”: “” name9 \ “”}, “10”: {“city”: “” city10 \ “”, “name”: “” name10 \ “”}}

diccionario3
We will change the characters using the block: replace all text
we note that it admits all enfants terribles.

1 Like

3.- Now with Dictionary

We create a list of pairs, but we observe that several characters (quotation mark, space, \n) do not want to enter the string to work with the list, so we will introduce them in the list of pairs by using the block add items to list.
We will introduce that list of pairs in the dictionary.

(we could also have entered the characters " space \ n directly in the dictionary)

"{",""\n"\",""\n"“",""\n"”",""\n":",","\n

1 Like

4.- With Web1.JsonTextDecode and Dictionary.

In the JsonTextDecode string we cannot use the \ ", so we replace it with the replace all text block (or with value for key in dictionary).

jsonText=
[["{", ""], [":", ","], ["},","\n"], ["“", ""], ["”", ""], [" ", ""],["}}", ""]]

1 Like

5.- Transliteration.

Transliteration is exchange the characters from one language to another, for example from Greek to Latin.
This is a proposal …

Here is another example to convert json to list.

[ {"id":"20","fields":{"ID":"342","Nombre":"Juan","Edad":46,"Nivel":5,"Ciudad":"Puerto de Santamaría","Profesión":"Electricista"},"Hora":"2020-04-27T18:32:46.000Z"},
{"id":"21","fields":{"ID":"223","Nombre":"Antonio","Edad":23,"Nivel":4,"Ciudad":"Conil","Profesión":"Fontanero"},"Hora":"2020-05-27T15:32:33.000Z"},
{"id":"22","fields":{"ID":"893","Nombre":"José","Edad":38,"Nivel":5,"Ciudad":"Cádiz","Profesión":"Soldador"},"Hora":"2020-06-27T22:32:22.000Z"},
{"id":"23","fields":{"ID":"765","Nombre":"Pedro","Edad":51,"Nivel":3,"Ciudad":"San Fernando","Profesión":"Mecánico"},"Hora":"2020-07-27T11:30:52.000Z"},
{"id":"24","fields":{"ID":"650","Nombre":"Luis","Edad":19,"Nivel":2,"Ciudad":"Medina Sidonia","Profesión":"Conductor"},"Hora":"2020-08-27T09:22:49.000Z"}]


p8n2d_diccionario.aia (5.4 KB)

http://kio4.com/appinventor/8N2D_Diccionario_json.htm

1 Like