-
Notifications
You must be signed in to change notification settings - Fork 170
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
[Copilot No. Series] Add Json functionality for working with JSON data #716
Conversation
Add new Json module to provide tools for working with JSON data, including reading, writing, and parsing JSON. Introduces codeunit for initializing JSON array and object, retrieving element counts, fetching objects by index, and getting values for specified record fields. Implements methods to interact with JSON data using .NET types. This is partly ported from Base Application codeunit 5459 "Json management"
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests missing before code review can continue.
Added app.json file defining a JSON module and its dependencies, as well as a new codeunit "Json Test" containing tests for JSON functionality, specifically around JSON collection manipulation and value extraction. This enhances the system's testing capabilities around JSON processing.
Add individual functions to retrieve various data types from JSON objects, like strings, boolean, integer, decimals etc.
I'm generally happy with this module! Clean API, well tested! If you get rid of the last two codecop issues which prevent compilation, I'll get another set of eyes on this and in it goes. |
…bles order declaration The GetObjectFromCollectionByIndex method signature has been modified to accept the index parameter before the JSON object in text format parameter. This change aims to improve consistency and adherence to best practices.
Pushed commit with fixes. Please take a look |
…pulate JSON arrays Added functions to modify, add, or remove properties, as well as manipulate JSON arrays. Extracted JSON array and object retrieval methods to improve code readability and maintainability. These changes enhance the flexibility and reusability of JSON handling.
New commit 354ecd2 is pushed with the fixes on the provided comments and also new apis, together with new tests |
@duichwer, are you happy with this PR now? If you are, I'll do some manual testing and will do a detailed review, and then we're good to go here, I'd say. |
In general I'm Okay with this PR for now. I'm never sure which overloads are possible in AL. If this isn't possible then I'd suggest to rename those procedures to something like GetObjectAsText Besides that I'm totally fine with this PR. |
Two more build issues: We're getting there :) |
You cannot overload on the return type alone. The parameters must be different. Why not go with the "AsText" suggestion? It makes it very clear in which shape you'll get the object / collection. I'd vote for that. |
Refactor JSON codeunit methods to return JSON array and object directly as well as in text format, enhancing flexibility and usability. Update related test cases accordingly.
It's done. |
We also have PTECop and UICop enabled but I think the thing you need is to use the same ruleset as we do:
|
My apologies. When I was looking into the settings file, I was working on the BaseApp. Addendum: The ruleset used here is base.ruleset.json, which I don't know if we're actually shipping (will find out). For the System App and Business Foundation, we've indeed got all 4 cops enabled with the internal.module.ruleset.json when compiling modules individually, and the ruleset.json when compiling the entire layer into an app. This I indeed should document :-) |
Simplify and restructure JSON parsing methods to enhance readability and provide greater flexibility for handling JSON data. These changes also aim to improve maintainability and extensibility of the codebase. No related issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me now. Approved!
Adding .NET dependency.
Co-authored-by: Darrick <[email protected]>
Consolidate variable declaration to enhance code readability and maintainability. This change eliminates redundancy and streamlines the code structure.
Apply namespace changes Co-authored-by: Darrick <[email protected]>
I like this one! Are there usage examples avaibalbe anywhere (asides from the Tests :D)? |
You can find some additional examples here or just search for |
Add new Json module to provide tools for working with JSON data, including reading, writing, and parsing JSON. Introduces codeunit for initializing JSON array and object, retrieving element counts, fetching objects by index, and getting values for specified record fields. Implements methods to interact with JSON data using .NET types.
This is partial implementation of the
Base Application
codeunit 5459 "Json management"
Summary
This PR is required for the Number Series Copilot implementation as we agreed here
Work Item(s)
Fixes #715
Fixes AB#506714