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 array encoding fails on array of objects #50976
Comments
Without having it debugged, I would say the reason is that Line 883 in 87d7c8f
Lines 834 to 838 in 87d7c8f
Lines 508 to 523 in 87d7c8f
|
Hi Markus, Thank you for your quick analysis. After debugging this, your explanation perfectly matches my observations. Now the question is: does this behavior deserves to be enhanced or not ? This is probably not a must have. But anyone could unintentionally end up with JSON descriptors not matching C structure. So telling explicitly somewhere in the documentation that we can't do that would be a plus. I'll try to work on it (because I need it anyway), let's see if I can enchance this behavior without breaking everything. Totally aside of this:
|
This issue 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 issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fix zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Not stale, pending PR |
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fix zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Introduce SIZEOF_FIELD helper macro Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Introduce SIZEOF_FIELD helper macro Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This issue 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 issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fix zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fix zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Add special handling for nested arrays This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Add special handling for nested arrays This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Add special handling for nested arrays This enhancement fix encoding of JSON objects for which descriptors do not covers all members of the C structure represented. Fixes zephyrproject-rtos#50976 Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
Hi,
When I try to encode an array of objects. If the descriptors of the inner object doesn't cover all the fields of the object structure, then the array is wrongly encoded.
Normal case:
With the previous code, the json is properly encoded :
But if I uncomment the line
uint32_t b;
.Here, "b" member is still not encoded in the JSON, but I would have expect the result to be the same, however I get the following result. Array is incorrectly encoded.
If I set "b" to "0xFFFFFFFF" in initialization loop, it seems that the value of "b" is used sporadically. This highlights that the encoder reads the values at incorrect offsets while encoding the array.
Is this just an undocummented unhandled case ? I do understand this case has not been foreseen.
Impact
Impact is that we cannot use C structure (for JSON encoding) which are not exhaustively described using descriptors. In my case, I will not be able to use existing structure if there are fields I don't want to encode, I would need to create structures dedicated to JSON encoding.
I haven't done much debugging yet, maybe I will dig into this when I have time.
Environment:
The text was updated successfully, but these errors were encountered: