Fill ListView from json string

Hi there, I need your help to parse a json string to charge on a Listview.
Here is string
[{"Art":"SOMEARTICLE","Nr":"3,00","Qnt":"12,00","Prz":"2,90","Tot":"36,19"}]
I should to pick every detail from this string and charge them on LV in this format

SOMEARTICLE NR: 3,00 Qnt: 12,00 Prz 2,90

but I'm not able to do it

I have tried in this way

Thanks

This:

Does this:

image

Thanks Timai, It could be good but there are many Art on list, so I think it would be better to put the result on the same line like this
Art Some art Nr 2.00 Qnt: 12.00 Prz: 23.00
and so on

It will/may split over two lines anyway,so why not make it more readable.....

I have made this changes and it seems accettable. I have to adjust better, becouse I don't want row Total in the same line

Edit:
It isn't resolutive. It analize only one row, but I hace to cycle in multiple row.

Show how you want the output in the listview to look

Something like this

Art Some art Nr 2.00 Qnt: 12.00 Prz: 23.00
Art Someart2 Nr 3.00 Qnt: 9.00 Prz: 11.00
Art Someart3 Nr 4.00 Qnt: 5.00 Prz: 6.00
Art Some art Nr 7.00 Qnt: 7.00 Prz: 9.00

...and so on

Where did "Tot : 123" go ?

and show the json with multiple rows (in text, not image)

A the end of the list, but as tou can imagine, in another verticallayout.
(thanks)

Answer questions in detail.

I answered Tamai above, sadly I don't have an emulator to produce a screenshot, but I placed the output just how each row of the listview should be. I hope it is clear

Art Some art Nr 2.00 Qnt: 12.00 Prz: 23.00
Art Someart2 Nr 3.00 Qnt: 9.00 Prz: 11.00
Art Someart3 Nr 4.00 Qnt: 5.00 Prz: 6.00
Art Some art Nr 7.00 Qnt: 7.00 Prz: 9.00

Tim asks what the raw Json data looks like. In the first post you showed only 1 line of Json data. Show more data struct in Json.

Generally some data with quantity differences.
Imagine having to fill a shopping list, you could find bread, milk, beer and other things, so as to have the item with the relative quantity and price in the same line.

Is that your whole Json? I don't think so...so show all Json or more than just one record. Just show Json with more articles. Tim will need it for testing.

Sure!
This is an example with 3 Articles

[{"Art":"BANANE","Col":"3,00","Qnt":"12,00","Prz":"2,00","Tot":"24,00"},{"Art":"BEER","Col":"2,00","Qnt":"12,00","Prz":"1,50","Tot":"18,00"},{"Art":"COFFEE","Col":"1,00","Qnt":"2,50","Prz":"4,00","Tot":"10,00"}]

then, by query, I can calculate the entire amount.

1 Like

OK, this:

returns this:

image

1 Like

It was definitely a demanding and long enough job and I thank you for that. The solution works and returns the data in the form I expected, but apart from the solution, which is certainly a very important help, I wanted to ask where it would be possible to find some tutorials for managing json strings, which from what I learned in this weeks, can have different shapes and structures. I really like MIT App and since I use databases a lot and the query results come in json form, I would like to learn how to handle strings and how to get the data I need.
Thanks again.

There's one more thing I wanted to ask you: as you can see yourself, the setting of the data in each row, follows the order Art - Col - Prz - Qnt but I don't understand why since the Json string has the order "Art - Col - Qnt - Prz - Total"
Is there any way to manipulate this order? You didn't specify a specific key, but I see you iterated through the string values ​​using each key in the list. I don't understand why the original order is broken down.

  1. A good place to start is to read the AI2 documentation on Dictionaries and Lists (they are occasionally interchangeable, and json strings often contain list brackets (json arrays). Then you have the world wide web and google at your disposal for other learning resources on json.

  2. When converting a json string to a dictionary in AI2 you will often find that keys (and their values attached) are returned in a different order, and again, often in alpha-numeric order. If you want to output in a particular order then you will need to do some more work to select each key in your preferred order to return the values.

Thanks Timai, I will do it