Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Question] Is there a way to visit an element of array twice in ondemand API? #2298

Unanswered
zhanglistar asked this question in Q&A
Discussion options

Hi, all. I am working on using ondemand API to parse json. I have to visit an json data twice, first to get types and then elements, since they are split into two seperate classes, do we have this feature support?
Thanks a lot.

You must be logged in to vote

Replies: 3 comments

Comment options

Please see the rewinding section of our documentation:

https://github.com/simdjson/simdjson/blob/master/doc/basics.md#rewinding

You must be logged in to vote
0 replies
Comment options

Please see the rewinding section of our documentation:

https://github.com/simdjson/simdjson/blob/master/doc/basics.md#rewinding

@lemire Thanks for your reply. I have read this documentation, and both rewind and reset can not satisfy my need directly(maybe rewind is OK, but I need refactor all code and flow). In fact, do we have or plan to do this API: get a position first, and then, you can restore it latter. For example,
auto cars_json = R"( [
{ "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] },
{ "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] },
{ "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] }
] )"_padded;
There is a position of tire_pressure in the second object, and I can still rewind to this place, and read the value again?
Thanks a lot.

You must be logged in to vote
0 replies
Comment options

I can still rewind to this place, and read the value again?

If you need to access the same value multiple times, you should store it in your own data structure.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2295 on December 02, 2024 04:47.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.