Skip to content

[Ruby] Extended JSON #168

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

Merged
merged 10 commits into from
Jul 28, 2025
Merged

Conversation

rachel-mack
Copy link
Contributor

@rachel-mack rachel-mack commented Jul 23, 2025

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-51421

Staging Links

  • data-formats/extended-json
  • data-formats
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?
    • Are the page titles greater than 20 characters long and SEO relevant?

    Copy link

    netlify bot commented Jul 23, 2025

    Deploy Preview for docs-ruby ready!

    Name Link
    🔨 Latest commit 5233654
    🔍 Latest deploy log https://app.netlify.com/projects/docs-ruby/deploys/6887ae1091d8c800088ff8ef
    😎 Deploy Preview https://deploy-preview-168--docs-ruby.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify project configuration.

    @rachel-mack rachel-mack changed the title shared content [Ruby] Extended JSON Jul 23, 2025
    @docs-builder-bot
    Copy link

    docs-builder-bot commented Jul 23, 2025

    🔄 Deploy Preview for docs-ruby processing

    Item Details
    🔨 Latest Commit d8fdf3bb7d290cdf30e3aa735c998c283e8e8814
    😎 Deploy Preview https://deploy-preview-168--docs-ruby.netlify.app
    🔍 Build Logs View Logs

    Copy link
    Collaborator

    @norareidy norareidy left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Looks good so far! I left some minor comments

    Comment on lines 70 to 73
    You can write an Extended JSON string from a hash by using the
    ``as_extended_json()`` method. Using the Ruby ``map{}`` method, you can create
    an Extended JSON string from an array of hashes. By default, this method returns
    the Extended JSON string in canonical format, but you can specify relaxed or
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    S: I was a little confused by this description of both the as_extended_json() method and map{}, and which one "this method" refers to. I think you can just describe as_extended_json() in this intro section, then talk about map further down:

    Suggested change
    You can write an Extended JSON string from a hash by using the
    ``as_extended_json()`` method. Using the Ruby ``map{}`` method, you can create
    an Extended JSON string from an array of hashes. By default, this method returns
    the Extended JSON string in canonical format, but you can specify relaxed or
    You can write an Extended JSON string from a hash by using the
    ``as_extended_json()`` method. By default, this method returns
    the Extended JSON string in canonical format, but you can specify relaxed or

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Good call out. I moved the map description to the example intro below.

    @rachel-mack rachel-mack requested review from a team and jamis and removed request for a team July 25, 2025 16:23
    Copy link
    Collaborator

    @norareidy norareidy left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM with a couple nits!

    Comment on lines 32 to 34
    json_array_canonical = hash_array.map(&:as_extended_json)
    json_array_relaxed = hash_array.map{ |hash| hash.as_extended_json(mode: :relaxed) }
    json_array_legacy = hash_array.map{ |hash| hash.as_extended_json(mode: :legacy) }
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Note that the bson library also defines Array#as_extended_json, which does pretty much what you have (mapping the array so each element has the method invoked on it as well).

    (See https://github.com/mongodb/bson-ruby/blob/master/lib/bson/array.rb#L104-L108)

    Suggested change
    json_array_canonical = hash_array.map(&:as_extended_json)
    json_array_relaxed = hash_array.map{ |hash| hash.as_extended_json(mode: :relaxed) }
    json_array_legacy = hash_array.map{ |hash| hash.as_extended_json(mode: :legacy) }
    json_array_canonical = hash_array.as_extended_json
    json_array_relaxed = hash_array.as_extended_json(mode: :relaxed)
    json_array_legacy = hash_array.as_extended_json(mode: :legacy)

    Comment on lines 69 to 70
    and legacy formats. It calls the ``as_extended_json()`` method from inside a
    Ruby ``map{}`` block to create the Extended JSON string from an array of hashes:
    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    As noted in a later comment, you can invoke #as_extended_json directly on an array instance.

    Suggested change
    and legacy formats. It calls the ``as_extended_json()`` method from inside a
    Ruby ``map{}`` block to create the Extended JSON string from an array of hashes:
    and legacy formats. It calls the ``#as_extended_json`` method on an array to create the
    Extended JSON string from an array of hashes:

    Also, Ruby convention refers to instance methods as #method_name, rather than method_name().

    @rachel-mack rachel-mack changed the base branch from master to comp-cov July 28, 2025 17:02
    @rachel-mack rachel-mack merged commit 52cf4c1 into mongodb:comp-cov Jul 28, 2025
    5 checks passed
    rachel-mack added a commit to rachel-mack/docs-ruby that referenced this pull request Jul 30, 2025
    * DOCSP-51932: v2.21.2 patch release (mongodb#163)
    
    * shared content
    
    * write
    
    * link formatting
    
    * link formatting
    
    * NR feedback
    
    * NR feedback
    
    * JB feedback
    
    * rephrase
    
    * remove extra change
    
    ---------
    
    Co-authored-by: Nora Reidy <nora.reidy@mongodb.com>
    rachel-mack added a commit that referenced this pull request Jul 30, 2025
    * DOCSP-51932: v2.21.2 patch release (#163)
    
    * change TOC name (#165)
    
    * add a redirect (#169)
    
    * [Ruby] TOC Reorg (#160)
    
    * toc reorg
    
    * tweaks
    
    * DOCSP-51415 Add causal consistency section (#161)
    
    * [Ruby] CRUD - Upsert (#164)
    
    * DOCSP-51932: v2.21.2 patch release (#163)
    
    * add upsert section
    
    * reference
    
    * LM feedback
    
    * checkout snooty
    
    ---------
    
    Co-authored-by: Nora Reidy <nora.reidy@mongodb.com>
    
    * DOCSP-51416 Network Compression (#162)
    
    * [Ruby] Load Balancers (#166)
    
    * DOCSP-51932: v2.21.2 patch release (#163)
    
    * client option
    
    * undo snooty change
    
    * formatting
    
    * formatting
    
    * DR feedback
    
    ---------
    
    Co-authored-by: Nora Reidy <nora.reidy@mongodb.com>
    
    * [Ruby] Extended JSON (#168)
    
    * DOCSP-51932: v2.21.2 patch release (#163)
    
    * shared content
    
    * write
    
    * link formatting
    
    * link formatting
    
    * NR feedback
    
    * NR feedback
    
    * JB feedback
    
    * rephrase
    
    * remove extra change
    
    ---------
    
    Co-authored-by: Nora Reidy <nora.reidy@mongodb.com>
    
    ---------
    
    Co-authored-by: Nora Reidy <nora.reidy@mongodb.com>
    Co-authored-by: shuangela <angela.shu@mongodb.com>
    Co-authored-by: Jordan Smith <45415425+jordan-smith721@users.noreply.github.com>
    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