Bruno Grenier
Posts: 0
Joined: Thu Aug 20, 2015 9:41 pm

How mapping Json in item list dynamically

Example:
jsonVariable = [
{"name":"person1", "phone":1234, "address":"address1"},
{"name":"person2", "phone":1234, "address":"address2"},
{"name":"person3", "phone":1234, "address":"address3"},
{"name":"person4", "phone":1234, "address":"address4"}....
......
{"name":"person1000", "phone":1234, "address":"address1000"},
{"name":"person5000", "phone":1234, "address":"address5000"},
]

I need to map these in ITEM LIST:
label1: name
label2: phone
label3: address

DYNAMICALLY, but in JAVASCRIPT.
The json IS NOT stored in localstorage array!
thanks

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How mapping Json in item list dynamically

Hello Bruno,

Could you clarify what have you tried and what exactly does not work?
Mapping documentation: https://devcenter.appery.io/documenta...

Bruno Grenier
Posts: 0
Joined: Thu Aug 20, 2015 9:41 pm

How mapping Json in item list dynamically

1- I have a JSON stored as STRING on LOCALSTORAGE:
"[{"name":"person1", "phone":1234, "address":"address1"},
{"name":"person2", "phone":1234, "address":"address2"},
{"name":"person3", "phone":1234, "address":"address3"},
{"name":"person4", "phone":1234, "address":"address4"}....
......
{"name":"person1000", "phone":1234, "address":"address1000"},
{"name":"person5000", "phone":1234, "address":"address5000"},
]"

2- I will transform this STRING into JSON:

var personsString = Apperyio.storage.personsLocalStorage.get()
var personsObject = JSON.parse(personsString);

3- I need to put this JSON (personsObject) in a listview:
Image

Is a lot of "persons" in personsObject.

I want to create a listview with this, but i don't know how to MAPPING this variable (personsObject) in listview.

What do you sugest me?

Tks a lot!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How mapping Json in item list dynamically

Bruno,

You haven't parse personsLocalStorage variable. You have to:
1) Create service "persons"
2) Add it to the page
3) Add mapping from storage variable to the listitem, on it's complete event

Return to “Issues”