I want to put some lists of lists in a dictionary. I'm getting strange results. Shouldn't I be able to do this?
Peter
August 3, 2021, 5:39am
3
This is because your use the same names so it picks the last one. MARK 4 and JOHN 3. The names should be unique.
1 Like
Really? The dictionary will work, or not work, depending on what's in it? When you say "names", these are data values. So if I have a dictionary with a thousand items in it, and the user happens to enter some values that are the same, it breaks?
I'm am new to all this, but that doesn't seem right.
You should undestand the json structure of dictionary, within an object you can not have two identical keys
but you can have an array with objects with same keys
I use jsonparseonline to check my json's stucture and I believe this guide might help you
0 — Basics 0.1 — What Is Dictionary Dictionary is actually object JSON. Therefore, you have to know the basics of JSON. It is a way to store information in an organized, easy-to-access manner. It is formed with a key, and a value. It is called a...
Reading time: 4 mins 🕑
Likes: 74 ❤
1 Like
I'll study on this. I need to know JSON better.
1 Like
Actually, this is a bug in App Inventor that causes the list of lists to be coerced into a dictionary rather than keeping the provided structure. Someone has submitted a fix and it will be in the next release.
1 Like
Peter
August 3, 2021, 1:50pm
8
If i remember right it is this one
opened 11:53PM - 02 Feb 21 UTC
closed 03:38PM - 16 Mar 21 UTC
bug
help wanted
status: new
affects: ucr
priority: high
**Describe the bug**
<!--
Describe the bug in sufficient detail so that we c… an understand the issue. You should also describe the steps to reproduce the issue (below) so that we ideally can confirm it.
-->
[Forum post](https://community.appinventor.mit.edu/t/problem-with-dictionary-of-list-of-lists/25850/2?u=ewpatton): Passing a list-of-lists as a value in the dictionary constructor converts it into a dictionary unexpectedly. Using a set block to update an empty dictionary does the correct thing (storing the list in the dict).
**Affects**
<!--
Please check off the part of the system that is affected by the bug.
-->
- [ ] Designer
- [ ] Blocks editor
- [x] Companion
- [x] Compiled apps
- [ ] Buildserver
- [ ] Debugging
- [ ] Other... (please describe)
**Expected behavior**
<!--
Please describe what you expected to happen before you encountered the bug.
-->
The value should be stored unmodified in the dictionary.
**Steps to reproduce**
<!--
Please describe the steps needed to reproduce the bug. If possible, please include a minimal example project that demonstrates the issue.
-->
1. Create a list of lists
2. Create a dictionary, setting mapping a string key to the list-of-lists value
3. Print the dictionary using Do It or a label, observe that the what should be a list of lists is now a dictionary
Hi all,
I've created a list of lists and stored it inside a dictionary.
[Schermata 2021-02-03 alle 00.20.36]
The dictionary stores the list of lists created in the image above as a dictionary {1:10 , 3:4, 5:6, 7:8} (this is the result that print the second alert) and sadly I can't understand why.
How can I store a list of lists in a dictionary and then retrieve the same list of lists?
edit:
Also converting the list of lists in dictionary and then converting again from dictionary to list o…
ABG
August 3, 2021, 3:18pm
9
The ai2-test server works okay for this.
system
Closed
August 10, 2021, 3:18pm
10
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.