Skip to content

Add NativeJsonFieldMapper and JsonFieldMapperInput classes; update se… - #133

Merged
AhmadRAbuhussein merged 1 commit into
releases/r8.0from
native-mapper
Mar 29, 2026
Merged

Add NativeJsonFieldMapper and JsonFieldMapperInput classes; update se…#133
AhmadRAbuhussein merged 1 commit into
releases/r8.0from
native-mapper

Conversation

@hamzahalq

@hamzahalq hamzahalq commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

…rvice collection to register new handlers

Summary by CodeRabbit

Release Notes

  • New Features
    • Added JSON field mapping capability to transform and reorganize JSON data using configurable mapping rules.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new JSON field mapping handler is introduced, providing a native adapter that parses incoming JSON data and applies field mapping rules to transform the data structure. Configuration is provided via a startup input class containing mapping rule definitions.

Changes

Cohort / File(s) Summary
JSON Field Mapper Core
SW.Bitween.NativeAdapters/JsonFieldMapper/JsonFieldMapperInput.cs, SW.Bitween.NativeAdapters/JsonFieldMapper/NativeJsonFieldMapper.cs
New JsonFieldMapperInput POCO with required Rules property. New NativeJsonFieldMapper handler implementing INativeInfolinkHandler that parses JSON, applies field mapping rules (with support for scalar and array mappings), and returns transformed JSON. New MappingRule record defines mapping configurations with OutputField, SourcePath, and optional FixedValue.
DI Registration
SW.Bitween.NativeAdapters/ServiceCollectionExtensions.cs
Updated service collection extension to register NativeJsonFieldMapper as scoped implementation for both INativeInfolinkHandler and INativeAdapter interfaces.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Handler as NativeJsonFieldMapper
    participant Rules as Mapping Rules
    participant JSON as JSON Data
    
    Client->>Handler: Initialize with rules config
    Handler->>Rules: Deserialize Rules from settings
    Rules->>Handler: MappingRule[] loaded
    
    Client->>Handler: Handle(XchangeFile)
    Handler->>JSON: Parse input data as JSON
    JSON->>Handler: JSON object created
    
    Handler->>Rules: Filter & separate scalar/array rules
    
    loop For each scalar rule
        Handler->>JSON: Apply fixed value OR copy from source
        JSON->>Handler: Field set
    end
    
    loop For each array rule group
        Handler->>JSON: Iterate source array elements
        loop Per element
            Handler->>JSON: Construct output object
            Handler->>JSON: Apply array rules with [*] indexing
        end
    end
    
    Handler->>JSON: Serialize to string
    Handler->>Client: Return new XchangeFile
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Muhannad/native adapters changes #125: Directly introduces the same NativeJsonFieldMapper and JsonFieldMapperInput features with identical registration in AddNativeAdapters, representing the primary implementation for this JSON field mapping capability.

Suggested reviewers

  • mmalkhatib

Poem

🐰 A mapper hops through JSON fields with care,
Rules transform data floating in the air,
Scalar paths and arrays too,
Fixed values mixed with mappings new! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding NativeJsonFieldMapper and JsonFieldMapperInput classes and updating service collection registration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch native-mapper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@AhmadRAbuhussein
AhmadRAbuhussein merged commit fa49f1e into releases/r8.0 Mar 29, 2026
3 of 4 checks passed
@MusaMisto
MusaMisto deleted the native-mapper branch July 2, 2026 09:27
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