Uh oh!
There was an error while loading. Please reload this page.
[Ruby] Extended JSON - #168
Conversation
✅ Deploy Preview for docs-ruby ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🔄 Deploy Preview for docs-ruby processing
|
norareidy
left a comment
There was a problem hiding this comment.
Looks good so far! I left some minor comments
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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 |
There was a problem hiding this comment.
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:
| 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 |
There was a problem hiding this comment.
Good call out. I moved the map description to the example intro below.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
norareidy
left a comment
There was a problem hiding this comment.
LGTM with a couple nits!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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) } |
There was a problem hiding this comment.
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)
| 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) |
| 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: |
There was a problem hiding this comment.
As noted in a later comment, you can invoke #as_extended_json directly on an array instance.
| 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().
5a4773f to
5233654CompareUh oh!
There was an error while loading. Please reload this page.
* 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>
* 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>
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-51421
Staging Links
Self-Review Checklist