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

feat(p/json): Update JSON package with new validators and functions #1869

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

notJoon
Copy link
Member

@notJoon notJoon commented Apr 1, 2024

Description

This pull request updates the JSON package with new validators and functions. It includes the following changes:

New Feature

  • Added Validate function to apply a list of validators to a node.
  • Added Filter function to filter children of an object or array node based on a predicate.
  • Added Update to update the value or add a new key-value pair to an object node.
  • Added UpdateValue function to update the value of a node.

FIX

  • Updated the README and invalid explanations in comment

@notJoon notJoon requested review from a team as code owners April 1, 2024 09:28
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

Hey @notJoon! Thanks for improving the package. I left some comments that might not need to be addressed in this PR. Take a look at them if you can and leave your thoughts.

I will play around with the package a bit to test out the performance.

@@ -96,29 +101,33 @@ Encoding (or Marshaling) is the functionality that converts JSON data represente

> ⚠️ Caution: Converting a large `Node` type into a JSON string may _impact performance_. or might be cause _unexpected behavior_.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: or might be cause _unexpected behavior_.

@@ -71,23 +71,28 @@ Decoding (or Unmarshaling) is the functionality that converts an input byte slic

The converted `Node` type allows you to modify the JSON data or search and extract data that meets specific conditions.

Below is an example of converting a `Node` type into a JSON string, and retrieving all the keys in the JSON data with `json.UniqueKeyLists()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you break lines in .md files at 80 chars for easier readability in raw mode ;)

@@ -71,23 +71,28 @@ Decoding (or Unmarshaling) is the functionality that converts an input byte slic

The converted `Node` type allows you to modify the JSON data or search and extract data that meets specific conditions.

Below is an example of converting a `Node` type into a JSON string, and retrieving all the keys in the JSON data with `json.UniqueKeyLists()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a little bit confusing that you're calling a whole JSON string a Node, and then you have each subfield as a Node as well. Was there a specific reason to not call the fields inside the JSON string Fields? Like, FieldString or StringField? WDYT?

@@ -71,23 +71,28 @@ Decoding (or Unmarshaling) is the functionality that converts an input byte slic

The converted `Node` type allows you to modify the JSON data or search and extract data that meets specific conditions.

Below is an example of converting a `Node` type into a JSON string, and retrieving all the keys in the JSON data with `json.UniqueKeyLists()`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any metrics on the package? What about adding a few classic test cases to see the performance (with gno test . -print-runtime-metrics)? I think this would also turn into a great piece of code for VM stress-testing later down the line.

@zivkovicmilos
Copy link
Member

Hey @notJoon, is this PR still relevant?

If so, can you please update it with the latest master?

Copy link

github-actions bot commented Jan 1, 2025

This PR is stale because it has been open 3 months with no activity. Remove stale label or comment or this will be closed in 3 months.

@github-actions github-actions bot added the Stale label Jan 1, 2025
@moul
Copy link
Member

moul commented Jan 1, 2025

@gfanton, save us 🙏

@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 1, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: notJoon/gno-core)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@github-actions github-actions bot removed the Stale label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

5 participants