You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm processing a data structure that is an object with a list of results containing maps of properties describing a row in a data table.
The names of the properties may contain spaces so using cljs-bean's bean function with a custom key fn to process it, lowercase the keys, and replace any spaces with dashes (-).
Just run it to show the data, the expected, and the actual data which should match the above. It will then enter a repl from which the data may be inspected, or you may fork it to directly edit the files.
I don't really understand why it prints the way I would expect, but processing it shows a different result.
That does work, returning the expected list value but it seems to be ignoring the call to bean with a specific prop->key fn to lower-case the keys. It does not match what gets printed.
The text was updated successfully, but these errors were encountered:
As far as I can tell, prop->key is used when creating derived values and key->prop is used when pre-processing keys for field lookup. Your prop->key turns "UID" into :uid, but your key->prop does not turn :uid into "UID", so cljs-bean ends up looking for a field named uid.
While I'm glad to have a better understanding of this library now, I'm not confident in the approach given that the prop->key is not always going to be able to follow specific rules and will require a lot of overrides as use-cases come up. Plus I'm not going back to js at all with this data so it may not be fully necessary.
p-himik shared an example of processing it manually in Clojurians Slack which seems to work well for my purposes:
jaidetree
changed the title
[BUG]: Data prints as expected but cannot be access as expected?
Data prints as expected but cannot be access as expected?
Mar 14, 2022
I'm processing a data structure that is an object with a list of results containing maps of properties describing a row in a data table.
The names of the properties may contain spaces so using cljs-bean's
bean
function with a custom key fn to process it, lowercase the keys, and replace any spaces with dashes (-
).To make it easier to reproduce, here's a replit with this exact problem recreated with the above test data.
https://replit.com/@eccentric-j/nbb-cljs-bean-oddity-repro#src/cli/core.cljs
Just run it to show the data, the expected, and the actual data which should match the above. It will then enter a repl from which the data may be inspected, or you may fork it to directly edit the files.
I don't really understand why it prints the way I would expect, but processing it shows a different result.
If you run:
That does work, returning the expected list value but it seems to be ignoring the call to bean with a specific
prop->key
fn to lower-case the keys. It does not match what gets printed.The text was updated successfully, but these errors were encountered: