Skip to content

Refactor: Merge JSON serializer implementations into unified JsonSerializer#2577

Merged
robfrank merged 4 commits into
mainfrom
copilot/fix-dbd26c6c-9028-4dd4-bd86-5258860836cf
Sep 30, 2025
Merged

Refactor: Merge JSON serializer implementations into unified JsonSerializer#2577
robfrank merged 4 commits into
mainfrom
copilot/fix-dbd26c6c-9028-4dd4-bd86-5258860836cf

Conversation

Copilot AI commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

This PR consolidates two duplicate JSON serialization implementations that were serving different parts of the codebase:

  • com.arcadedb.serializer.JsonSerializer - Used by HTTP handlers and query processing
  • com.arcadedb.database.JSONSerializer - Used by document classes for JSON serialization

Problem

Having two separate JSON serializers created maintenance overhead and potential inconsistencies:

// HTTP handlers used this approach
JsonSerializer serializer = JsonSerializer.createJsonSerializer();
JSONObject result = serializer.serializeDocument(document);

// While document classes used this approach  
JSONSerializer serializer = new JSONSerializer(database);
JSONObject result = serializer.map2json(map, type, includeMetadata);

Solution

Enhanced JsonSerializer to include all functionality from JSONSerializer, then updated all usages across the codebase:

Enhanced JsonSerializer with:

  • Database constructor for schema-aware operations
  • map2json() method with property filtering and metadata support
  • json2map() method for JSON-to-map conversion
  • Type conversion methods (convertToJSONType, convertFromJSONType)
  • Proper handling of embedded documents, collections, dates, and maps

Updated classes:

  • Core document classes: BaseDocument, MutableDocument, ImmutableDocument, DetachedDocument
  • Network remote classes: RemoteImmutableDocument, RemoteMutableDocument, etc.
  • Test classes and integration modules

Removed:

  • com.arcadedb.database.JSONSerializer class
  • All imports and references to the deprecated implementation

Benefits

  • Single source of truth for JSON serialization logic
  • Reduced maintenance burden - one class to maintain instead of two
  • Consistent behavior across HTTP APIs and document serialization
  • 100% backward compatibility - all existing APIs work identically
  • Cleaner architecture - eliminated duplicate code

All existing functionality is preserved, and the change is completely transparent to consumers of the JSON serialization APIs.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactoring: merge 2 JSON serializer implementations</issue_title>
<issue_description>Currently we have com.arcadedb.serializer.JsonSerializer, used by the HTTP handlers, and com.arcadedb.database.JSONSerializer, used by the documents to serialize into JSON</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #2004

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits September 28, 2025 21:07
… usages

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactoring: merge 2 JSON serializer implementations Refactor: Merge JSON serializer implementations into unified JsonSerializer Sep 28, 2025
Copilot AI requested a review from robfrank September 28, 2025 21:13
@robfrank robfrank requested a review from lvca September 28, 2025 21:28
@codacy-production

codacy-production Bot commented Sep 28, 2025

Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.24% 68.97%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (340426c) 72462 45835 63.25%
Head commit (173ddfc) 72538 (+76) 45709 (-126) 63.01% (-0.24%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2577) 87 60 68.97%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@robfrank robfrank marked this pull request as ready for review September 30, 2025 09:28
@robfrank robfrank merged commit 3782597 into main Sep 30, 2025
25 of 31 checks passed
@robfrank robfrank deleted the copilot/fix-dbd26c6c-9028-4dd4-bd86-5258860836cf branch September 30, 2025 09:29
robfrank added a commit that referenced this pull request Nov 10, 2025
…onSerializer (#2577)

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
(cherry picked from commit 3782597)
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.

Refactoring: merge 2 JSON serializer implementations

2 participants