Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_array() is True, but raise 'cannot use operator[] for object iterators' #1880

Closed
estelll opened this issue Dec 26, 2019 · 2 comments
Closed
Labels
kind: question state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@estelll
Copy link

estelll commented Dec 26, 2019

  • Describe what you want to achieve.
    There are two array A, B in the same size. In python I can use zip(A, B) to get elements from them at the same time. But I am not sure how to get it using this cpp.

  • Describe what you tried.
    I first get the array size by 'A.size()', then I iterate the index from 0 to the size. And using A[idx] and B[idx] to get elements separately.
    However, it raise

 terminate called after throwing an instance of 'nlohmann::detail::invalid_iterator'
  what():  [json.exception.invalid_iterator.208] cannot use operator[] for object iterators

And I am sure A and B is an array instead of object since I A.is_array() is True and B.is_array() is True too

  • Describe which system (OS, compiler) you are using.
    LInux

  • Describe which version of the library you are using (release version, develop branch).
    develop branch, 3.7.0

@nlohmann
Copy link
Owner

Can you provide a code example?

@stale
Copy link

stale bot commented Jan 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jan 25, 2020
@stale stale bot closed this as completed Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

2 participants