api/internal/campaign/json_util library

Safe JSON readers mirroring Android's JSONObject.optX helpers.

The campaign config arrives as untyped Map<String, dynamic> decoded from the backend. These helpers coerce values defensively so a malformed field never throws — matching the lenient parsing behaviour of the Android SDK.

Functions

optBool(Map<String, dynamic> json, String key, bool fallback) → bool
optDouble(Map<String, dynamic> json, String key, double fallback) → double
optInt(Map<String, dynamic> json, String key, int fallback) → int
optList(Map<String, dynamic> json, String key) → List?
optMap(Map<String, dynamic> json, String key) → Map<String, dynamic>?
optPositiveInt(Map<String, dynamic> json, String key, int fallback) → int
optString(Map<String, dynamic> json, String key, [String fallback = '']) → String

Exceptions / Errors

ReportedParseFailure
A parse failure already reported under its own reason, so the campaign is dropped without a second malformed_campaign_skipped.