Add JsonElement.GetPropertyCount()#106222
Conversation
|
Note regarding the |
1 similar comment
|
Note regarding the |
|
@eiriktsarpalis I still have some issues with the result of |
|
Oh, interesting. This suggests that there might be an issue with the value of the It might be worth investigating what the value represents in objects and see if there's an easy way to obtain the actual property count from it. |
…/runtime into json-get-property-count
| int propertyCount = 0; | ||
| int objectOffset = index + DbRow.Size; | ||
| int innerDepth = 0; | ||
| for (; objectOffset < _parsedData.Length; objectOffset += DbRow.Size) |
There was a problem hiding this comment.
The issue with this approach is that needs to perform a traversal of the entire object to compute the size. This is already possible with EnumerateObject(), we should only include this API if we can guarantee that it's constant-time.
Were you able to determine what the row.SizeOrLength value represents in the case of objects and if so, can be meaningfully used (or changed) so that we can obtain the property count?
There was a problem hiding this comment.
Some test cases failed when I tried to update the SizeOrLength for object properties count, so I tried this way.
Would try to update the SizeOrLength to do some research on the failed cases, thanks for the input
|
closed in favor of #106503 |
fixes #104692