Collecting accurate data in the field often means dealing with poor or completely absent internet connectivity. At the same time, modern surveys rely heavily on conditional logic – questions that appear or disappear depending on prior responses. We needed a solution that could deliver both: 100% offline capability and complex, rule-based dynamic survey flows.
To meet this challenge, we built a powerful yet lightweight iOS application (designed primarily for iPads) that uses a JSON-driven rule engine to control survey behavior entirely on the device.
The Challenge
Field researchers frequently operate in locations where:
- Network availability is inconsistent
- Surveys require multi-level conditional logic
- Responses must be validated instantly
- Large-scale questionnaires must remain maintainable
Traditional survey platforms struggle in these conditions. Our goal was to build an app that works anywhere, supports advanced branching logic, and ensures high-quality data at the point of collection.
Our Solution: A JSON-Powered Offline Survey Application
As a mobile app development company experienced in offline-first architectures, we created an iOS app that stores all survey data locally and uses a custom JSON rule engine to drive question flow.
- Smooth operation with zero connectivity
- Real-time logic execution
- Instant validation and error alerts
- Fully customizable surveys without changing the application code
Architecture Overview
1. The Rule Engine
At the heart of our system is a lightweight rule engine designed to evaluate boolean expressions. It reads JSON configurations and determines:
- Which question to show
- Which to skip
- When to trigger validations and alerts
The engine executes these rules dynamically and instantly, enabling seamless branching logic throughout the survey.
2. Question Structure
Each question follows a simple and intuitive JSON-based design:
- Question content – text, input type, UI behavior
- Conditions array – rules determining if the question should be shown
- Processes – post-answer actions for:
- Data reporting
- Smart validation and alerts
This structure is deliberately minimal, making it easy to maintain even for non-technical survey designers.
Conditional Logic Made Simple
The conditions system supports two logical combinations:
- All conditions (AND logic) – every condition must be true
- Any conditions (OR logic) – at least one condition must be true
When the surveyor reaches a question:
- The engine evaluates its conditions
- If true, the question appears
- If false, the question is skipped
- The engine advances to the next question automatically
This approach supports complex skip patterns and ensures a natural, context-aware flow.
Smart Data Validation
To improve data accuracy, the application runs a dual-process validation pipeline after every answer.
1. Reporting Process
This process assigns values to internal identifiers – what we call bank codes.
These stored values can then be referenced by future conditions, enabling multi-step dynamic logic.
2. Alerting Process
The app actively checks for unusual responses and immediately prompts the surveyor to reassess.
Examples of alerts include:
- A household marked with 0 bathrooms
- A residential home with no kitchen
- Responses falling outside expected real-world ranges
This real-time feedback helps prevent errors before the data even leaves the field.
Why This Approach Works
✔ Simplicity
The array-based JSON structure is easy to understand, modify, and visualize—no complex flowchart tools needed.
✔ Flexibility
Boolean expressions enable highly advanced survey logic while remaining lightweight and fast.
✔ Reliability
Because everything is stored and processed locally, the app works flawlessly even without internet access.
✔ Data Quality
Immediate alerts catch inaccurate entries at the moment they occur, dramatically improving overall data integrity.
Technical Implementation
- Language: Swift
- Platform: iOS (iPad-optimized)
- Storage: Local database for offline operation
- Logic: JSON-based rule engine fully separate from application code
Survey logic updates require no app update – just replace the JSON configuration.
Managing Large-Scale Surveys (600+ Questions)
When our survey expanded to nearly 600 questions, a single JSON file became impossible to maintain. Updating or testing such a large configuration was inefficient and error-prone.
Our Solution: Modular JSON Architecture
We broke the survey into multiple logical sections, each in its own JSON file:
- demographics.json
- household_characteristics.json
- amenities.json
- economic_activities.json and more
Benefits of Modularization
1. Section-Level Testing
Each section could be validated independently.
If we changed the demographics section, we only retested those ~50 questions, not the entire survey.
2. Collaboration-Friendly
Multiple team members could work on different sections without conflicts.
3. Safe Updates
Changes to one file couldn’t accidentally break logic in another section.
4. Meaningful Version Control
Git diffs became clear and focused:
Instead of “600 lines changed,” we saw “demographics updated with new age brackets.”
Deployment Process
Before deploying to field devices, we built an automated process to ensure quality.
Our build script:
- Validates each JSON section for syntax and schema accuracy
- Runs automated logic tests on conditions within each section
- Combines all sections into a single master survey JSON
- Bundles the final configuration with the iOS app
This approach gives us modular development with unified runtime behavior – the best of both worlds.
Conclusion
This project demonstrates that complex, dynamic surveys don’t require cloud dependence or heavy infrastructure. By combining:
- A clean, JSON-driven rule engine
- Local data storage
- Modular survey design
- Smart real-time validation
We created a reliable survey application that works anywhere – offline, online, urban, or remote.