-
Notifications
You must be signed in to change notification settings - Fork 175
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
get function can not retrieve the value from an json object which have complex key name. #441
Comments
No need for const routeCfg = configs[routeName] ?? {} Lodash uses a complicated and much less performant regex approach, which apparently works in your case because the period Due to its simplified implementation, I would avoid using Radash P.S. Check out Radashi, an actively maintained fork of Radash with many improvements and new functions |
Why I want to use either radash.get() or loads.get() method is because the configs object can be undefined, I don’t want it to throw an error. |
const routeCfg = configs?.[routeName] ?? {} |
How about the key here is a multiple level key of nested objects? |
Don't know what you mean. Give an example with input data and expected result. Use triple backticks to quote the code, so I can copy-paste it. |
Think of the scenario where you want to use get method to retrieve a json value. Anw, I just want to report a bug here, not asking for workaround 🤣 |
It's not really a bug, just a limitation. Something is only a bug if it's a documented behavior that isn't working as expected. You're actually making a feature request. Semantics aside, if we can't understand your use case, we can't solve your problem. That's where a minimal example helps much more than you'd think. It's quite possible your expectation is unrealistic and you're using the wrong tool for the job. We're all guilty of such things, now and again. |
Ok, you can take this as a feature request, but I believe many people are just like me, we don’t quite understand its subtle limitations before using a “replacement“ function which other libraries can work. And then why I would like to use get methods? According to what you said, there are always ways to get the value in the json object without using third-party libraries and functions, just using a lot of conditional statements and non-null judgments to ensure that no errors are thrown. |
get function can not get value from below json object, but lodash can! 😂
{"/api-v1.2": "some-value"}
The text was updated successfully, but these errors were encountered: