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

Refactor and improve json_prolog/2 predicate #782

Merged
merged 8 commits into from
Oct 12, 2024

Conversation

ccamel
Copy link
Member

@ccamel ccamel commented Oct 11, 2024

Purpose

This PR introduces a series of refactors for the json_prolog/2 predicate to improve its behaviour and alignment with common Prolog and JSON encoding conventions:

  • Object keys now maintain their original order during conversion, rather than being sorted. This ensures consistency with the input structure and enhances marshalling performance.
json_prolog('{"b": 1, "a": 2}', json([b=1,a=2])). /* true */
json_prolog('{"foo": "bar"}', json([foo=bar])). /* true */
  • Empty arrays are now uniformly encoded with the empty-list atom [], replacing the previous @([]) encoding method.
json_prolog('[]', []).  /* true */

Impact

⚠️ The PR introduces some breaking changes that will mainly affect the KatAI app, particularly in relation to the zone governance.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced JSON handling with improved error reporting and conversion functions.
    • Introduced new ForEach function for iterating over list elements.
  • Bug Fixes

    • Improved error handling in JSON parsing and Prolog assertions.
  • Tests

    • Added comprehensive tests for new and existing functions, ensuring robust validation of JSON and Prolog functionalities.
  • Documentation

    • Updated comments and variable names for clarity and better understanding of functionality.

@ccamel ccamel self-assigned this Oct 11, 2024
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 91.20879% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
x/logic/predicate/json.go 89.11% 11 Missing and 5 partials ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #782      +/-   ##
==========================================
+ Coverage   41.88%   42.77%   +0.88%     
==========================================
  Files         108      108              
  Lines        5028     5078      +50     
==========================================
+ Hits         2106     2172      +66     
+ Misses       2812     2796      -16     
  Partials      110      110              
Files with missing lines Coverage Δ
x/logic/prolog/assert.go 58.65% <100.00%> (+11.84%) ⬆️
x/logic/prolog/error.go 0.00% <ø> (ø)
x/logic/prolog/json.go 100.00% <100.00%> (+32.00%) ⬆️
x/logic/prolog/list.go 78.26% <100.00%> (+33.81%) ⬆️
x/logic/predicate/json.go 89.69% <89.11%> (+2.49%) ⬆️

... and 1 file with indirect coverage changes

@ccamel ccamel force-pushed the refactor/json_prolog_improvements branch 2 times, most recently from 9e2fc0b to 6ffb303 Compare October 12, 2024 09:49
@ccamel ccamel marked this pull request as ready for review October 12, 2024 09:54
Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The pull request introduces significant modifications to the JSON handling logic within the Prolog engine. Key changes include the renaming of parameters, restructuring of the JSONProlog function, and the addition of new converter functions for better conversion between Prolog terms and JSON. Enhanced error handling, new global variables for error reporting, and comprehensive test coverage improvements are also included. Additional functions for key-value assertions and list iteration are introduced, along with corresponding tests to ensure robustness and clarity.

Changes

File Change Summary
x/logic/predicate/json.go Updated JSONProlog function with new parameter name and internal logic; added forwardConverter and backwardConverter functions; enhanced error handling; added new global variables for JSON error reporting; refactored encoding/decoding functions.
x/logic/predicate/json_test.go Updated test functions for improved error handling and added new test cases for edge scenarios; standardized queries to align with Prolog syntax; refined existing test cases for clarity.
x/logic/prolog/assert.go Introduced AssertKeyValue function; updated AssertPair to utilize a new helper function; adjusted error handling for functor type.
x/logic/prolog/assert_test.go Added TestAssertPair and TestAssertKeyValue functions to validate new assertions with comprehensive test cases.
x/logic/prolog/atom.go Added AtomKeyValue for key-value pairs; removed AtomEmptyArray.
x/logic/prolog/error.go Added AtomKTypeKeyValue; updated initialization for AtomTypeJSON and AtomValidEncoding.
x/logic/prolog/json.go Declared new global variables for JSON terms; updated JSONNull and JSONBool functions; removed JSONEmptyArray and ExtractJSONTerm; added AssertJSON function.
x/logic/prolog/json_test.go Renamed TestExtractJsonTerm to TestJSONNull; added TestJSONBool and TestAssertJSON functions; simplified assertions.
x/logic/prolog/list.go Introduced ForEach function for list iteration; reformatted import statement for the engine package.
x/logic/prolog/list_test.go New file created for unit tests of the ForEach function, covering various scenarios and edge cases.

Possibly related PRs

  • Fix/json float support #778: The changes in this PR directly modify the JSONProlog function and related test cases in json.go and json_test.go, enhancing JSON handling capabilities, which aligns closely with the significant modifications made in the main PR regarding the JSONProlog function and its associated logic.

Suggested reviewers

  • bdeneux
  • amimart

Poem

🐇 In the land of logic where rabbits play,
JSON dances in a bright new way.
With converters and tests, we hop with glee,
Error handling's better, as clear as can be!
So let’s celebrate, with a joyful cheer,
For changes that make our code so dear! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (9)
x/logic/prolog/list.go (2)

3-5: Consider keeping the single import on one line.

While the multi-line import is valid, it's more common in Go to keep single imports on one line for better readability. Consider reverting to:

import "github.com/axone-protocol/prolog/engine"

This aligns with Go's standard formatting practices.


24-49: Excellent implementation of the ForEach function.

The function is well-structured, handles errors appropriately, and provides a useful abstraction for iterating over Prolog lists. It aligns well with the PR objectives and enhances the package's functionality.

Consider a minor optimization to simplify the loop structure:

func ForEach(list engine.Term, env *engine.Env, f func(v engine.Term, hasNext bool) error) error {
	iter, err := ListIterator(list, env)
	if err != nil {
		return err
	}

	for iter.Next() {
		elem := iter.Current()
		hasNext := iter.Next()
		if err := f(elem, hasNext); err != nil {
			return err
		}
		if !hasNext {
			break
		}
		iter.Back() // Move back one step as we've advanced twice
	}

	return nil
}

This change eliminates the need for the initial if check and simplifies the loop structure. The iter.Back() call is added to correct the iterator position after checking for the next element.

x/logic/prolog/list_test.go (3)

1-11: LGTM! Consider avoiding dot import for better clarity.

The package declaration and imports look good. However, consider avoiding the dot import for the goconvey package:

-import (
-    ...
-    . "github.com/smartystreets/goconvey/convey"
-)
+import (
+    ...
+    "github.com/smartystreets/goconvey/convey"
+)

This change would improve code clarity by making it explicit where Convey and other functions come from.


22-30: Consider using goconvey assertions for the empty list case.

While the logic is correct, the test can be improved by using goconvey assertions instead of t.Errorf. This would make the test consistent with the rest of the file and provide better error messages.

Consider refactoring like this:

{
    description: "Empty list",
    list:        engine.NewAtom("[]"),
    f: func(_ engine.Term, _ bool) error {
        c.So(false, ShouldBeTrue, "Function should not be called for empty list")
        return nil
    },
},

This change ensures that if the function is called unexpectedly, the test will fail with a clear goconvey assertion message.


41-61: LGTM! Consider simplifying the closure for better readability.

The "List with elements" test case is well-designed and covers important aspects of the ForEach function. The use of a closure to maintain state across function calls is clever.

To improve readability, you might consider simplifying the closure:

{
    description: "List with elements",
    list:        engine.List(engine.NewAtom("a"), engine.NewAtom("b"), engine.NewAtom("c")),
    f: func() func(v engine.Term, hasNext bool) error {
        values := []string{"a", "b", "c"}
        i := 0
        return func(v engine.Term, hasNext bool) error {
            c.So(i, ShouldBeLessThan, len(values))
            got, err := AssertAtom(v, env)
            c.So(err, ShouldBeNil)
            c.So(got.String(), ShouldEqual, values[i])
            c.So(hasNext, ShouldEqual, i < len(values)-1)
            i++
            return nil
        }
    }(),
    wantError: nil,
},

This version moves the increment of i to the end of the function, eliminating the need for defer. It's a minor change but might make the code slightly easier to follow.

x/logic/prolog/error.go (1)

48-49: LGTM! Consider enhancing the comment.

The addition of AtomKTypeKeyValue aligns well with the PR objectives, particularly the change in encoding key-value pairs. The naming convention is consistent with other atom type declarations in the file.

Consider enhancing the comment to provide more context, such as:

// AtomKTypeKeyValue is the term used to indicate the key-value type.
// This is used in the new encoding of key-value pairs using the '=' functor.
x/logic/prolog/json.go (1)

28-37: Consider adding unit tests for AssertJSON

To ensure the correctness and reliability of the AssertJSON function, consider adding unit tests that cover both valid and invalid cases.

x/logic/prolog/json_test.go (1)

57-62: Remove unused wantResult field from test cases

In TestAssertJSON, the wantResult field in the test cases struct is declared but not utilized in the assertions. Removing this unused field will clean up the code and eliminate any potential confusion.

Apply this diff to remove the unused field:

 cases := []struct {
 	description string
 	input       engine.Term
 	wantError   error
-	wantResult  string
 }{
 	{
 		description: "valid JSON object",
 		input:       AtomJSON.Apply(engine.NewAtom("valid")),
 		wantError:   nil,
 	},
x/logic/predicate/json.go (1)

96-96: Increase test coverage for new code paths

The static analysis has flagged that several new lines are not covered by tests. These lines include error handling and edge cases critical to the JSON encoding and decoding logic. Improving test coverage will help ensure that these code paths work as expected and will prevent regressions in the future.

Would you like assistance in identifying specific test cases or in writing tests to cover these lines?

Also applies to: 121-121, 124-124, 137-137, 141-141, 145-145, 165-165, 168-168, 176-176, 184-184, 199-199, 208-208, 228-229, 237-238, 267-267, 276-276, 290-290

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 96-96: x/logic/predicate/json.go#L96
Added line #L96 was not covered by tests

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cab7137 and 6ffb303.

⛔ Files ignored due to path filters (1)
  • docs/predicate/json_prolog_2.md is excluded by !docs/predicate/**/*.md
📒 Files selected for processing (10)
  • x/logic/predicate/json.go (3 hunks)
  • x/logic/predicate/json_test.go (9 hunks)
  • x/logic/prolog/assert.go (1 hunks)
  • x/logic/prolog/assert_test.go (1 hunks)
  • x/logic/prolog/atom.go (1 hunks)
  • x/logic/prolog/error.go (2 hunks)
  • x/logic/prolog/json.go (1 hunks)
  • x/logic/prolog/json_test.go (1 hunks)
  • x/logic/prolog/list.go (2 hunks)
  • x/logic/prolog/list_test.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
x/logic/predicate/json.go

[warning] 96-96: x/logic/predicate/json.go#L96
Added line #L96 was not covered by tests


[warning] 111-112: x/logic/predicate/json.go#L111-L112
Added lines #L111 - L112 were not covered by tests


[warning] 121-121: x/logic/predicate/json.go#L121
Added line #L121 was not covered by tests


[warning] 124-124: x/logic/predicate/json.go#L124
Added line #L124 was not covered by tests


[warning] 137-137: x/logic/predicate/json.go#L137
Added line #L137 was not covered by tests


[warning] 141-141: x/logic/predicate/json.go#L141
Added line #L141 was not covered by tests


[warning] 145-145: x/logic/predicate/json.go#L145
Added line #L145 was not covered by tests


[warning] 165-165: x/logic/predicate/json.go#L165
Added line #L165 was not covered by tests


[warning] 168-168: x/logic/predicate/json.go#L168
Added line #L168 was not covered by tests


[warning] 176-176: x/logic/predicate/json.go#L176
Added line #L176 was not covered by tests


[warning] 184-184: x/logic/predicate/json.go#L184
Added line #L184 was not covered by tests


[warning] 199-199: x/logic/predicate/json.go#L199
Added line #L199 was not covered by tests


[warning] 208-208: x/logic/predicate/json.go#L208
Added line #L208 was not covered by tests


[warning] 228-229: x/logic/predicate/json.go#L228-L229
Added lines #L228 - L229 were not covered by tests


[warning] 237-238: x/logic/predicate/json.go#L237-L238
Added lines #L237 - L238 were not covered by tests


[warning] 267-267: x/logic/predicate/json.go#L267
Added line #L267 was not covered by tests


[warning] 276-276: x/logic/predicate/json.go#L276
Added line #L276 was not covered by tests


[warning] 290-290: x/logic/predicate/json.go#L290
Added line #L290 was not covered by tests

🔇 Additional comments (27)
x/logic/prolog/list.go (1)

Line range hint 1-49: Overall, excellent additions to the prolog package.

The new ForEach function is a valuable addition that aligns well with the PR objectives. It provides a clean and efficient way to iterate over Prolog lists, enhancing the package's functionality. The implementation is robust, with proper error handling and use of existing utilities like ListIterator.

The only minor suggestion is to consider the import statement formatting and the small optimization in the ForEach function's loop structure. These changes would further improve the code's readability and efficiency.

Great work on this implementation!

x/logic/prolog/list_test.go (3)

13-78: Well-structured test function and test cases!

The TestForEach function is correctly declared, and the test case structure is well-designed. It covers various scenarios including empty list, non-list term, list with elements, and error handling. This comprehensive approach ensures thorough testing of the ForEach function.


80-91: Well-structured test execution loop!

The test execution loop is well-implemented. It correctly iterates over all test cases, uses Convey for proper test organization, and performs appropriate error checking based on the wantError field of each test case. This structure ensures that each test case is executed independently and that the results are clearly reported.


1-91: Excellent test coverage and structure for the ForEach function!

This test file provides comprehensive coverage for the ForEach function, including edge cases and error scenarios. The use of goconvey for BDD-style testing enhances readability and maintainability. The suggested improvements are minor and aimed at consistency and slight readability enhancements.

Great job on writing thorough and well-structured tests!

x/logic/prolog/atom.go (2)

39-41: LGTM: Addition of AtomKeyValue aligns with PR objectives

The introduction of AtomKeyValue is a positive change that aligns well with the PR objectives. It implements the use of the = functor for encoding key-value pairs, which enhances readability and consistency with SWI-Prolog's standard encoding practices. The comment clearly explains its purpose and usage.


Line range hint 1-41: Verify the removal of AtomEmptyArray

The AI summary mentions the removal of AtomEmptyArray, which aligns with the PR objective of uniformly encoding empty arrays using the empty-list atom []. However, this change is not visible in the provided code snippet. Could you please confirm if AtomEmptyArray has been removed from this file?

Additionally, it appears that AtomEmptyList (line 16) might now be used for representing empty arrays. Can you verify if this is the case?

To help verify these changes, you can run the following script:

✅ Verification successful

Removal of AtomEmptyArray Confirmed

The AtomEmptyArray identifier has been successfully removed from x/logic/prolog/atom.go. The AtomEmptyList is now being utilized consistently across the codebase to represent empty arrays, aligning with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of AtomEmptyArray and the usage of AtomEmptyList

# Test 1: Check if AtomEmptyArray is still present in the file
echo "Checking for AtomEmptyArray:"
rg "AtomEmptyArray" x/logic/prolog/atom.go

# Test 2: Check the usage of AtomEmptyList in the codebase
echo "Checking usage of AtomEmptyList:"
rg "AtomEmptyList" --type go

Length of output: 747

x/logic/prolog/error.go (3)

Line range hint 1-145: Overall, the changes look good and align with the PR objectives.

The modifications improve consistency in atom declarations and enhance the handling of JSON and key-value pairs. The suggested verifications will help ensure that these changes don't introduce unintended side effects. The minor improvements in comments will further enhance code clarity and maintainability.


61-62: LGTM! Verify impact and consider documentation update.

The changes to AtomValidEncoding improve clarity and consistency. The new examples in the comment provide better context.

Please verify that changing "valid_encoding" to "encoding" doesn't break existing code. Run the following script to check for any remaining usages of "valid_encoding":

#!/bin/bash
# Description: Check for any remaining usages of "valid_encoding"

# Test: Search for "valid_encoding" usage
rg --type go '"valid_encoding"'

Consider updating any related documentation or user guides that might reference the old "valid_encoding" term to reflect this change.


51-51: LGTM! Verify impact on existing code.

The modification of AtomTypeJSON to use engine.NewAtom("json") instead of AtomJSON aligns with the PR objectives and ensures consistency with other atom type declarations.

Please verify that this change doesn't break any existing code that might have been using AtomJSON. Run the following script to check for any remaining usages of AtomJSON:

x/logic/prolog/json.go (4)

7-11: Consolidate common term applications into variables

Great job defining nullTerm, trueTerm, and falseTerm variables. This enhances performance by avoiding repeated calls to AtomAt.Apply and improves code readability.


16-16: Use precomputed nullTerm in JSONNull function

Returning nullTerm directly makes the JSONNull function more efficient and avoids unnecessary computations.


22-25: Simplify JSONBool function with precomputed terms

Utilizing trueTerm and falseTerm in the JSONBool function simplifies the code and enhances performance.


28-37: Introduce AssertJSON function for type assertion

The new AssertJSON function provides a clear and efficient way to assert that a term is a JSON object. It improves error handling by returning a type error when the term does not match the expected format.

x/logic/prolog/json_test.go (2)

12-24: TestJSONNull function is correctly implemented

The test accurately verifies that JSONNull() returns the expected JSON null atom. The use of Compare for term comparison is appropriate.


54-91: TestAssertJSON function effectively covers various scenarios

The TestAssertJSON function thoroughly tests the AssertJSON function with multiple cases, including valid inputs and expected errors. The assertions correctly validate the outcomes based on the input provided.

x/logic/prolog/assert.go (2)

157-158: LGTM! Function AssertPair correctly delegates to assertTuple2WithFunctor.

The refactoring improves code reuse by utilizing assertTuple2WithFunctor with appropriate parameters.


174-178: LGTM! Enhanced flexibility in assertTuple2WithFunctor.

Modifying assertTuple2WithFunctor to accept functor and functorType as parameters increases its reusability for different tuple structures.

x/logic/prolog/assert_test.go (1)

427-427: ⚠️ Potential issue

Fix syntax error in test case initialization

In the test case "a key-value pair with non-atom key", the term field is incorrectly initialized. It currently has a syntax error due to an extra comma and missing AtomKeyValue.Apply, which results in invalid syntax and incorrect test setup.

Apply this diff to fix the syntax error:

-				term:      engine.Integer(42), StringToAtom("value")),
+				term:      AtomKeyValue.Apply(engine.Integer(42), StringToAtom("value")),

Likely invalid or redundant comment.

x/logic/predicate/json_test.go (9)

70-104: Refactored key-value representations enhance readability

The test cases in lines 70-104 have been updated to use = instead of - for key-value pairs in Prolog terms. This change aligns with standard Prolog syntax and improves code readability.


174-174: Standardized empty array representation

Line 174 updates the handling of empty arrays to use [], conforming to Prolog's list notation and ensuring consistency in array representation.


205-238: Expanded test coverage for malformed JSON inputs

The new test cases between lines 205-238 effectively test the handling of various malformed JSON inputs. This enhancement improves the robustness of error handling in the json_prolog/2 predicate.


276-304: Enhanced object conversion from Prolog to JSON

Updates in lines 276-304 refine the conversion of Prolog terms to JSON, especially for objects with multiple attributes and special characters. These changes ensure accurate serialization and alignment with expected JSON formats.


Line range hint 310-343: Improved error detection for invalid Prolog terms

The test cases from lines 310-343 introduce checks for invalid Prolog structures when converting to JSON. This ensures that type errors and incorrect key-value definitions are properly detected and reported.


354-361: Corrected number array conversion to JSON

Lines 354-361 verify the conversion of Prolog arrays of numbers to JSON. The updates confirm that numerical arrays are accurately serialized, maintaining data integrity.


412-414: Accurate handling of empty Prolog lists

Line 412 ensures that empty Prolog lists are correctly converted to JSON arrays, enhancing consistency between Prolog lists and JSON array representations.


476-482: Consistency in unification regardless of formatting

The test case in lines 476-482 confirms that the json_prolog/2 predicate correctly unifies JSON and Prolog terms even when formatting varies. This reinforces the predicate's reliability in different input scenarios.


551-586: Comprehensive bidirectional conversion tests for complex structures

The test cases from lines 551-586 add thorough evaluations of complex nested structures during JSON-Prolog conversions. These tests improve confidence in the predicate's ability to handle intricate data forms, including nested objects, arrays, and special values like null and booleans.

x/logic/prolog/json_test.go Show resolved Hide resolved
x/logic/prolog/assert.go Outdated Show resolved Hide resolved
x/logic/prolog/assert.go Outdated Show resolved Hide resolved
x/logic/predicate/json.go Show resolved Hide resolved
x/logic/predicate/json.go Show resolved Hide resolved
x/logic/predicate/json.go Show resolved Hide resolved
@ccamel
Copy link
Member Author

ccamel commented Oct 12, 2024

@coderabbitai pause

Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

✅ Actions performed

Reviews paused.

Object keys are no longer sorted in json_prolog/2. The original
order of keys is now preserved to maintain consistency with the input structure.
Empty arrays in Prolog are now consistently encoded using the
empty-list atom [].
…n_prolog/2

and align with the encoding convention used in SWI-Prolog.
@ccamel ccamel force-pushed the refactor/json_prolog_improvements branch from 6ffb303 to 6a1d677 Compare October 12, 2024 12:43
Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Great thanks, this is breaking indeed but better to do it now, we'll manage the changes in the KatAI app :)

@ccamel ccamel merged commit 025dd8b into main Oct 12, 2024
20 checks passed
@ccamel ccamel deleted the refactor/json_prolog_improvements branch October 12, 2024 16:51
@ccamel ccamel mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants