Skip to content

Conversation

otobrglez
Copy link
Contributor

Hey!

I've been a delighted user of Circe for years now. Love it!

I keep observing the pattern that I often just want to fetch a field from some deeply nested value (sometimes even with a "dynamic path"). So, I'm thinking if we could perhaps add a method next to downField, named downFields that would essentially achieve the following:

val nested: Json = Json.obj("hello" -> Json.obj("world" -> Json.obj("foo" -> Json.fromString("bar"))))

// Current example with downField
val cursorA: ACursor = 
  HCursor.fromJson(nested).downField("hello").downField("world").downField("foo")

// Simpler syntax with downFields
val cursorB: ACursor = 
  HCursor.fromJson(nested).downFields("hello", "world", "foo")

I've attached my implementation and tests to prove it works.

Please consider it and let me know if additional discussion or work is needed.

Regards,

- Oto

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.55%. Comparing base (1ea0e87) to head (2d57b05).
Report is 5 commits behind head on series/0.14.x.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@                Coverage Diff                @@
##           series/0.14.x    #2367      +/-   ##
=================================================
- Coverage          82.57%   82.55%   -0.02%     
=================================================
  Files                 94       94              
  Lines               3712     3721       +9     
  Branches             590      619      +29     
=================================================
+ Hits                3065     3072       +7     
- Misses               647      649       +2     
Flag Coverage Δ
2.12 84.15% <100.00%> (-0.97%) ⬇️
2.13 84.33% <100.00%> (-0.94%) ⬇️
3 81.17% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

otobrglez and others added 5 commits April 4, 2025 11:24
@otobrglez otobrglez requested a review from zarthross April 4, 2025 09:49
otobrglez and others added 2 commits April 7, 2025 09:44
@otobrglez otobrglez requested a review from zarthross April 7, 2025 07:57
@zarthross zarthross merged commit 68ab945 into circe:series/0.14.x Apr 7, 2025
18 checks passed
@otobrglez otobrglez deleted the down-fields branch April 8, 2025 09:09
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.

4 participants