-
-
Notifications
You must be signed in to change notification settings - Fork 8
Change additionalData from String to JSONObject #361 #362
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
base: main
Are you sure you want to change the base?
Change additionalData from String to JSONObject #361 #362
Conversation
## Walkthrough
The types of the `additionalData` fields in both `AssessmentEventGson` and `LearningEventGson` classes were changed from `String` to `JSONObject`, enabling structured JSON handling instead of plain text. Additionally, the `org.json:json` library was added as a Maven dependency. No other modifications were introduced.
## Changes
| File(s) | Change Summary |
|-----------------------------------------------------------------------------------------|-------------------------------------------------------------|
| src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java,<br>src/main/java/ai/elimu/model/v2/gson/analytics/LearningEventGson.java | Changed `additionalData` field type from `String` to `JSONObject` |
| pom.xml | Added `org.json:json` dependency for `JSONObject` support |
## Assessment against linked issues
| Objective (Issue #) | Addressed | Explanation |
|-------------------------------------------------------|-----------|-------------|
| Change `additionalData` from String to JSONObject (#361) | ✅ | |
## Suggested reviewers
- jpatel3
- SnehaHS65
- Souvik-Cyclic
---
elimu.ai's mission is to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java
(1 hunks)src/main/java/ai/elimu/model/v2/gson/analytics/LearningEventGson.java
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Maven CI
src/main/java/ai/elimu/model/v2/gson/analytics/LearningEventGson.java
[error] 12-30: Compilation error: cannot find symbol class JSONObject in LearningEventGson.java at lines 12 and 30.
src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java
[error] 12-51: Compilation error: cannot find symbol class JSONObject in AssessmentEventGson.java at lines 12 and 51.
🔇 Additional comments (1)
src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java (1)
51-51
: ```shell
#!/bin/bashShow the import statements for the two classes to verify JSONObject origin
echo "LearningEventGson imports:"
sed -n '1,20p' src/main/java/ai/elimu/model/v2/gson/analytics/LearningEventGson.javaecho -e "\nAssessmentEventGson imports:"
sed -n '1,20p' src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
* </pre> | ||
*/ | ||
private String additionalData; | ||
private JSONObject additionalData; |
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.
Add missing import for JSONObject to fix compilation error.
The pipeline failure indicates that JSONObject
cannot be resolved. Since this class uses Gson (evident from the class name and existing imports), consider using JsonObject
from Gson instead, which aligns better with elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months by ensuring robust, type-safe data structures.
Add the appropriate import at the top of the file:
import ai.elimu.model.v2.enums.analytics.LearningEventType;
import ai.elimu.model.v2.gson.BaseEntityGson;
+import com.google.gson.JsonObject;
import java.util.Calendar;
And update the field declaration:
- private JSONObject additionalData;
+ private JsonObject additionalData;
🧰 Tools
🪛 GitHub Actions: Maven CI
[error] 12-30: Compilation error: cannot find symbol class JSONObject in LearningEventGson.java at lines 12 and 30.
🤖 Prompt for AI Agents
In src/main/java/ai/elimu/model/v2/gson/analytics/LearningEventGson.java at line
30, the field additionalData is declared as JSONObject but the class lacks the
necessary import, causing a compilation error. Replace the type JSONObject with
Gson's JsonObject to maintain consistency with the Gson usage in the class, then
add the import statement for com.google.gson.JsonObject at the top of the file.
* </pre> | ||
*/ | ||
private String additionalData; | ||
private JSONObject additionalData; |
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.
Add missing import for JSONObject to fix compilation error.
The pipeline failure indicates that JSONObject
cannot be resolved. For consistency with the LearningEventGson
class and to leverage Gson's capabilities effectively, use JsonObject
from Gson. This ensures robust data handling that supports elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.
Add the appropriate import at the top of the file:
import ai.elimu.model.v2.enums.analytics.AssessmentEventType;
import ai.elimu.model.v2.gson.BaseEntityGson;
+import com.google.gson.JsonObject;
import java.util.Calendar;
And update the field declaration:
- private JSONObject additionalData;
+ private JsonObject additionalData;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private JSONObject additionalData; | |
// src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java | |
import ai.elimu.model.v2.enums.analytics.AssessmentEventType; | |
import ai.elimu.model.v2.gson.BaseEntityGson; | |
import com.google.gson.JsonObject; | |
import java.util.Calendar; | |
public class AssessmentEventGson extends BaseEntityGson { | |
// … other fields … | |
private JsonObject additionalData; | |
// … rest of class … | |
} |
🧰 Tools
🪛 GitHub Actions: Maven CI
[error] 12-51: Compilation error: cannot find symbol class JSONObject in AssessmentEventGson.java at lines 12 and 51.
🤖 Prompt for AI Agents
In src/main/java/ai/elimu/model/v2/gson/analytics/AssessmentEventGson.java at
line 51, the field additionalData is declared as JSONObject but the class
JSONObject is not imported, causing a compilation error. Replace JSONObject with
Gson's JsonObject for consistency and import com.google.gson.JsonObject at the
top of the file. Update the field declaration to use JsonObject instead of
JSONObject.
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.
@Ankush82 The code is not compiling: https://github.com/elimu-ai/model/actions/runs/15798807675/job/44534393831?pr=362
@jo-elimu Added the dependency for JSONObject in my latest commit. |
Issue Number
additionalData
from String to JSON #361Purpose
additionalData
field by changing its type fromString
toJSONObject
.Technical Details
private String additionalData;
field was replaced withprivate JSONObject additionalData;
.Testing Instructions
additionalData
usenew JSONObject(...)
instead of raw strings.Screenshots
Summary by CodeRabbit