You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases I have only integer index of Foo (i.e. 0) or Bar (i.e. 1), not a key like "Foo" or "Bar". And I'm need to erase "Bar" using only integer index. If I'm trying to erase "Bar" with using integer index, I'm getting an exception.
So, how I can (if it's possible) erase "Bar" using integer index? Or I need to use cycle like this for (auto it : obj) to find associative key by integer in first?
The text was updated successfully, but these errors were encountered:
How do you have an integer index into a map? Where did the index come from? There is no guarantee, given the code that you posted, that the data is in the same order in the map as in the source code.
I'm using items() to make list of obj items, after that I make this list visible for user. Indexes of this list is a valid indexes of json object. And user can choose one list item for delete.
Seems like your options are include the key data in the list, keep a vector of keys and get the key from the vector using the list index, or iterate through the items again until you get to the proper index, as there is no method that I know of to erase a map entry by index.
I have this object.
json obj = { {"Foo", 1}, {"Bar", 2} };
In some cases I have only integer index of
Foo
(i.e.0
) orBar
(i.e.1
), not a key like "Foo" or "Bar". And I'm need toerase
"Bar" using only integer index. If I'm trying to erase "Bar" with using integer index, I'm getting an exception.So, how I can (if it's possible) erase "Bar" using integer index? Or I need to use cycle like this
for (auto it : obj)
to find associative key by integer in first?The text was updated successfully, but these errors were encountered: