-
Notifications
You must be signed in to change notification settings - Fork 107
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
[JSON] Support Edit Values for JSON operator #1132
[JSON] Support Edit Values for JSON operator #1132
Comments
Hi Team, Is this issue currently open? I would like to work on this. |
hey @Prototype4988 , sounds great! I will assign this issue to you. |
Just a few questions.
|
@chuang8511 could you please help answer the technical questions here 🙏 |
Yes, actually, we have helped you finish the tasks.json & definition.json. So, what you have to do is only develop the golang code.
Usually, I create test code. You can refer to the |
@chuang8511 I have raised a draft PR. Can you check and let me know what you think of it. |
Hey @Prototype4988 Our team has provided some feedback in your PR. Could you check and update soon, thanks! Also don't forget to submit your contribution through this form to make it count: https://forms.gle/v3kdkKJKt8ZbSJYH6 |
@chuang8511 Just a quick question I have some trouble trying to create a recipe for this component I have been trying something like this instill-format doesnt seem to support object type. Do you know any recipe that uses json value as input which i could refer? |
It seems there is a bug fix a few days ago. Sample
|
@chuang8511 Any workaround you could suggest.
|
Hey @Prototype4988 could you check the comments left in your PR: instill-ai/pipeline-backend#761 and update accordingly so we can get this closed soon 🙏 thank you & happy hacking 🎃 |
@kuroxx I still have some doubts as mentioned below
|
Hi @Prototype4988 , How about trying this?
|
@chuang8511 It works but my question is how do i pass array of json as input since it looks like there is no support for instill-format: array:json |
Hi @Prototype4988 how's this going? I wanted to let you know that we will need a PR by the end of this week (8th Nov) since we are closing this event. Please submit:
to ensure your contribution is counted! Alternatively, if you cannot complete this within the time frame but would still like to contribute, you are more than welcome to but please note it would not be within the scope of Hacktoberfest 2024. Thank you and look forward to your contribution! ✨ |
Hi @kuroxx There is a bug as mentioned below which is a blocker against the development of the component
Will try to complete it within end of week provided there is a resolution or work around for the bug. @chuang8511 do you have any suggestions on the issue? |
Hey @Prototype4988 Could you check the documentation about Instill Format here. In general, you do not need to specify the array, you can just set it as For example: Input:
Recipe:
You can read about how to use JSON Marshal in the Documentation here too Let me know if this answers your questions ✨ |
Hey @Prototype4988 If not, then Hacktoberfest 2024 submissions will be closed but we look forward to your PR when it is ready 🙌✨ Update: as discussed in Discord, let's follow up on this after the event 😎 |
Issue Description
Current State
Proposed Change
JSON schema pseudo code
Edge Cases and Considerations:
1. Non-Existent Fields:
2. Type Mismatches:
Key Features:
field
: This specifies the exact location of the value to be edited. It allows for nested paths (e.g.,address.city
); otherwise, it treats the path as a literal key.newValue
: This is the new value that will replace the current value at the specifiedfield
.conflictResolution
Parameter:a.
create
: If the field does not exist, the function creates it.b.
skip
: If the field does not exist, the function skips the update (default behavior).c.
error
: If the field does not exist, the function logs an error or returns an error.Type Checking:
Before updating a value, the type of the existing field is checked to ensure compatibility.
Example Usage:
Scenario: Input data as JSON object
Conflict Resolution Scenarios:
1. Skip (Default):
Final output:
2. Alternate Scenario with "conflictResolution": "create":
If you had set "conflictResolution": "create", the "zipcode" field would have been created in the "address" object, and the output would look like this:
Final output:
3. Error:
If the conflictResolution is set to "error", the function will raise an error (or log an error) when it encounters a non-existent field during the update process. In this case, the update process will stop as soon as the non-existent field is encountered, and the existing fields will not be updated beyond that point.
Scenario: Input Data as an Array of Objects
If the input data is an array of objects, the logic needs to be adapted to handle each object in the array individually. The schema and the function would process each object within the array according to the specified updates and conflictResolution rules.
Input Example:
Explanation:
Output:
Rules for the Component Hackathon
Component Contribution Guideline | Documentation | Official Go Tutorial
The text was updated successfully, but these errors were encountered: