Skip to content

Conversation

@peno64
Copy link

@peno64 peno64 commented Nov 26, 2022

  • Add interator on LWJsonArray such that a foreach can be done over an array object
  • Implement ContainsKey to check if a key exists

…n array object

- Implement ContainsKey to check if a key exists
@progklb
Copy link
Owner

progklb commented Apr 9, 2023

Sorry for such a late reply on this! Life has been quite busy and I haven't looked at my personal projects in a while.

Thank you for the PR. I just wanted to discuss the reasoning behind some changes :)

  • Although adding a LWJson.ContainsKey is useful for overrides in key/value pair types, I don't see how it makes sense for pure arrays or value types. This is why I added it specifically to the LWJsonObject type, as it can represent key-value pairs. Are there cases where we would need ContainsKey for these other types?

  • I like the idea of adding the enumerator to the base LWJson - this is useful for LWJsonArray, as well as LWJsonObject, as we could return the value for each entry in the dictionary. However, I feel this gets a bit messy LWJsonValue as these can be pure value types (float, int, bool) and are not suitable for enumeration. Maybe a string-specific enumerator would be okay, but then the LWJson return type of this enumerator isn't suitable. So ultimately I feel like this isn't suitable as a base-class method.

Keen to hear your thoughts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants