-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
json: Fix multidimensional array support #50816
Conversation
556c752
to
fda1247
Compare
fda1247
to
f514b8b
Compare
@mrfuchs can you take a look at the CI failures? |
f13877f
to
5217b6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw this languishing and figured I should give it an approval, even though it's not really my area (we don't really have a maintainer for JSON right now, I guess?).
Language wonks (@stephanosio @keith-packard ?) might care about the unicode string literals, though they seem harmless to me.
2a388d8
to
55dc398
Compare
@mrfuchs Thank you, it worked for me 👍 |
Thank you! Unfortunately, I had to update this PR. Would you review it once more, please?
Yes, it's difficult to get JSON PRs approved - my last PR #47989 also got closed due to a lack of reviewers.
I didn't really pay attention to that. I just reused the test data that was already there. |
I noticed that my original patch would still not fix parsing arrays of objects. That's why I moved these lines inside the loop... Lines 578 to 583 in 55dc398
... and added a test for it (cf96b83). However, after adding the new unit test, CI failed again (for 64-bit targets only, cf. #36696 and #24372#issuecomment-617392567). So, I fixed this issue in 55dc398 to make CI work again. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Hey, I would like to inquire about the current status of this fix as I am experiencing the same issue as described here [(https://github.com//issues/59445)]. |
Will update this PR soon to follow @keith-packard's suggestion re. non-ascii text in the unit tests. |
14b6bc0
to
a0d34b3
Compare
@andyross, @keith-packard, I updated the unit tests. Could you review? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message on the first patch (fixing the bugs) provides no information about what was broken and how the change addresses that. Makes reviewing the patch pretty hard.
Unit test changes to use octal escapes look good! |
This patch fixes support for encoding and decoding multidimensional arrays as described by the JSON_OBJ_DESCR_ARRAY_ARRAY() macro. Currently, the JSON array encoding and decoding functions, arr_encode() and arr_parse(), expect array elements to be of object or primitive type. However, arrays may be nested and so an array's elements may also be arrays. In order to support nested arrays, two special cases must be considered: 1. The array of objects/arrays sub-descriptor is described by two `json_obj_descr` structs and so two instead of one `json_obj_descr` structs must be skipped when iterating over the JSON descriptor to get to an array's elements. 2. The implicit array item count field has to be considered for the parent itself and all its child array items when calculating an element's size. Fixes zephyrproject-rtos#50801 Signed-off-by: Markus Fuchs <[email protected]>
Switch the non-ascii text in the tests to use octal escape sequences to avoid potential compiler issues on platforms not defaulting to utf-8 text encodings. Signed-off-by: Markus Fuchs <[email protected]>
Fix encoded JSON string in test_json_decoding_array_array() test so it matches the described array object and add a test case for encoding arrays of arrays. Signed-off-by: Markus Fuchs <[email protected]>
Add tests for encoding and decoding two-dimensional arrays as described by the JSON_OBJ_DESCR_ARRAY_ARRAY() macro. Signed-off-by: Markus Fuchs <[email protected]>
Add tests for encoding and decoding nested arrays of objects located inside a parent object at a non-zero offset. Signed-off-by: Markus Fuchs <[email protected]>
This patch fixes encoding arrays of objects on 64-bit targets. Fixes zephyrproject-rtos#36696 Signed-off-by: Markus Fuchs <[email protected]>
I updated the commit message so it contains more information on what was missing and what was changed. |
After the changes introduced by zephyrproject-rtos#50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes zephyrproject-rtos#69297 Signed-off-by: Gerson Fernando Budke <[email protected]>
After the changes introduced by zephyrproject-rtos#50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes zephyrproject-rtos#69297 Signed-off-by: Gerson Fernando Budke <[email protected]>
After the changes introduced by #50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes #69297 Signed-off-by: Gerson Fernando Budke <[email protected]>
After the changes introduced by zephyrproject-rtos#50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes zephyrproject-rtos#69297 Signed-off-by: Gerson Fernando Budke <[email protected]> (cherry picked from commit 5fb62ca)
After the changes introduced by #50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes #69297 Signed-off-by: Gerson Fernando Budke <[email protected]> (cherry picked from commit 5fb62ca)
After the changes introduced by zephyrproject-rtos#50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes zephyrproject-rtos#69297 Signed-off-by: Gerson Fernando Budke <[email protected]>
After the changes introduced by #50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes #69297 Signed-off-by: Gerson Fernando Budke <[email protected]> (cherry picked from commit 5fb62ca)
After the changes introduced by #50816 the UpdateHub could not decode anymore the JSON object. This introduce missing parsing definitions to allow JSON parser undertood the correct UpdateHub probe object. Fixes #69297 Signed-off-by: Gerson Fernando Budke <[email protected]> (cherry picked from commit 5fb62ca)
This patch fixes support for encoding and decoding multidimensional arrays
as described by the JSON_OBJ_DESCR_ARRAY_ARRAY() macro.
Fixes #50801