Skip to content

Conversation

@SuriyaKannimuthu
Copy link
Contributor

@SuriyaKannimuthu SuriyaKannimuthu commented Nov 21, 2025

  • String Json parsing added in binding.

Summary by CodeRabbit

  • Bug Fixes
    • String variables containing JSON data are now correctly recognized and returned as JSON objects instead of quoted strings.

✏️ Tip: You can customize this high-level summary in your review settings.

@francispereira
Copy link

francispereira commented Nov 21, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Walkthrough

The getVariableValue method in the CleverTap Android plugin now attempts to parse String values as JSON. If parsing succeeds, the JSON string is returned unquoted; otherwise, non-JSON strings are wrapped in quotes as before. A new private helper method tryParseJson handles the detection and parsing logic.

Changes

Cohort / File(s) Summary
JSON Parsing Integration for Variable Strings
CleverTap/Plugins/Android/clevertap-android-wrapper.androidlib/src/main/java/com/clevertap/unity/CleverTapUnityPlugin.java
Modified getVariableValue to parse String values as JSON when applicable; introduced tryParseJson helper method to detect and parse JSON objects/arrays while gracefully falling back to quoted string wrapping for non-JSON values

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • JSON parsing logic edge cases: Verify the tryParseJson method handles malformed JSON, empty strings, and trimmed values correctly
  • Control flow validation: Ensure non-JSON strings still receive proper quote wrapping and existing behavior is preserved
  • Test coverage: Check that both JSON and non-JSON string scenarios are covered

Poem

🐰 Strings now shimmer with JSON's light,
Parsed with care, no quotes too tight,
The helper hops through brackets clean,
Returning data, sharp and keen!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 and specifically describes the main change: adding String JSON parsing functionality to the CleverTapUnityPlugin binding.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/SDK-5366/Fetching-JSON-Variables

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

@darshanclevertap
Copy link
Contributor

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@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: 0

🧹 Nitpick comments (1)
CleverTap/Plugins/Android/clevertap-android-wrapper.androidlib/src/main/java/com/clevertap/unity/CleverTapUnityPlugin.java (1)

1253-1267: tryParseJson implementation looks correct; consider minor robustness improvements

The helper is straightforward and does what you need: trims the string, parses {...} as JSONObject and [...] as JSONArray, and safely falls back to null on failure. Two optional refinements you might consider:

  • Log at debug/verbose level when parsing fails, if you ever need to diagnose malformed JSON arriving over the bridge.
  • If you ever need to support JSON primitives (e.g., 123, "foo", true as top‑level JSON), extend this method to handle those as well; right now only objects/arrays are recognized.

Not blockers, just future‑proofing ideas.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf11575 and 8b4138d.

📒 Files selected for processing (1)
  • CleverTap/Plugins/Android/clevertap-android-wrapper.androidlib/src/main/java/com/clevertap/unity/CleverTapUnityPlugin.java (2 hunks)
🔇 Additional comments (1)
CleverTap/Plugins/Android/clevertap-android-wrapper.androidlib/src/main/java/com/clevertap/unity/CleverTapUnityPlugin.java (1)

690-696: Behavior change for string variables that contain JSON

The new logic correctly treats string values that are valid JSON objects/arrays as JSON and returns them unquoted, falling back to the old "\"...\"" behavior otherwise. However, this is a breaking behavior change for any existing string variable whose value happens to start with { or [ and is valid JSON: Unity will now see a JSON object/array instead of a JSON string literal.

Please double‑check with SDK consumers (and/or add tests) to confirm that:

  • This change is intentional for all string variables, not just newly introduced “JSON variables”.
  • No existing integrations rely on always receiving a quoted string even when the content looks like JSON.

@SuriyaKannimuthu SuriyaKannimuthu merged commit 14f1c9e into develop Nov 25, 2025
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 25, 2025
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.

4 participants