Skip to content
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

Support list of objects for JSON #693

Merged
merged 2 commits into from
Feb 12, 2023

Conversation

RVRhub
Copy link
Contributor

@RVRhub RVRhub commented Feb 11, 2023

PR adds object list support for JSON.
An example of usage

JsonTransformer.<Name>builder().build().generate(
           Schema.of(
               field("text", () -> "Mrs. Brian Braun"),
               field("objectCollection", () -> List.of(
                       compositeField(null, new Field[]{
                               field("country", () -> "Denmark"),
                               field("city", () -> "Port Angel")
                           }
                       )
                   )
               )
           ), 1);

Result:

{"text": "Mrs. Brian Braun", "objectCollection": [{"country": "Denmark", "city": "Port Angel"}]}

@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2023

Codecov Report

Merging #693 (e38f556) into main (f1a3e50) will increase coverage by 0.04%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main     #693      +/-   ##
============================================
+ Coverage     92.40%   92.44%   +0.04%     
- Complexity     2603     2609       +6     
============================================
  Files           283      283              
  Lines          5318     5322       +4     
  Branches        573      573              
============================================
+ Hits           4914     4920       +6     
+ Misses          254      253       -1     
+ Partials        150      149       -1     
Impacted Files Coverage Δ
...net/datafaker/transformations/JsonTransformer.java 94.91% <100.00%> (+0.17%) ⬆️
src/main/java/net/datafaker/formats/Json.java 84.00% <0.00%> (-2.29%) ⬇️
.../main/java/net/datafaker/service/FakerContext.java 88.05% <0.00%> (+4.47%) ⬆️
...ain/java/net/datafaker/providers/base/Barcode.java 90.47% <0.00%> (+4.76%) ⬆️
...ain/java/net/datafaker/idnumbers/KoKrIdNumber.java 87.50% <0.00%> (+6.25%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@snuyanzin
Copy link
Collaborator

lgtm
also looking forward for update documentation

@hetzijzo
Copy link

hetzijzo commented May 5, 2023

As mentioned in #720 (comment) this is currently merged into 2.x (main) branch. Can this be merged into the existing 1.x branch as well?

@bodiam
Copy link
Contributor

bodiam commented May 5, 2023

@hetzijzo of course, and PRs world certainly be appreciated. Dankjewel ;)

snuyanzin pushed a commit to snuyanzin/datafaker that referenced this pull request May 7, 2023
* Add support list of objects in json transformer

* Add support list of objects in json transformer
snuyanzin pushed a commit to snuyanzin/datafaker that referenced this pull request May 7, 2023
* Add support list of objects in json transformer

* Add support list of objects in json transformer
snuyanzin added a commit that referenced this pull request May 7, 2023
* Add support list of objects in json transformer


Co-authored-by: Roman <r.romanv1@gmail.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
5 participants