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

Simplifying JSON_Iterate #118

Open
dachalco opened this issue Jul 7, 2022 · 0 comments
Open

Simplifying JSON_Iterate #118

dachalco opened this issue Jul 7, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@dachalco
Copy link

dachalco commented Jul 7, 2022

Two gripes regarding JSON_Iterate

  1. JSON arrays can't hold key-value pairs, just values. Requiring JSONPair_t when iterating arrays unnecessarily complicates user code. IMO there should be separate APIs for iterating arrays, and iterating collections -- can likely reuse existing implementation under the hood. Doing so would make user's code easier to read, as it'd be obvious where arrays are being iterated vs. non-arrays.

  2. It should only require one 'index' parameter for Iterating vs. having 2 separate parameters for start and next. The function is already modifying these index parameters, so why can't it just have one pulIndex where its value at entry serves as start, and the value of next is written back to pulIndex before returning?

Would be nice for JSON_Iterate:

  1. A parameter for specifying which array index, not index within buffer, would be nice if for example I only wanted to Iterate array[middle:end]. Sure, technically this is possible with current start and end parameters, however these are with respect to the buffer index. A user could call a JSON_Search("array[i]", ...) and do char * delta to compute an index, but that seems roundabout and sort of "hacky" vs. having this API honor some "array-index" parameter.
  2. Support for reverse array traversal. It's not uncommon for JSON arrays to be sorted. For example, I might have an array of objects sorted by creation time, and I might want to traverse from oldest-to-youngest or vice versa for different scenarios, or traverse backwards if my array is large and I know I want something closer to the end.
@kar-rahul-aws kar-rahul-aws added the enhancement New feature or request label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants