https://github.com/styropyr0/json_encoder
A library specifically made for arduino devices to encode JSON strings to URL strings and vice versa.
https://github.com/styropyr0/json_encoder
arduino arduino-ide arduino-json arduino-library arduino-uno arduino-web-client arduino-webserver esp32 json-decoder json-decoding json-encoder
Last synced: about 2 months ago
JSON representation
A library specifically made for arduino devices to encode JSON strings to URL strings and vice versa.
- Host: GitHub
- URL: https://github.com/styropyr0/json_encoder
- Owner: styropyr0
- Created: 2024-08-17T14:55:40.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T06:40:25.000Z (6 months ago)
- Last Synced: 2025-04-12T04:54:09.058Z (about 2 months ago)
- Topics: arduino, arduino-ide, arduino-json, arduino-library, arduino-uno, arduino-web-client, arduino-webserver, esp32, json-decoder, json-decoding, json-encoder
- Language: C++
- Homepage:
- Size: 4.88 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON_Encoder for Arduino
**JSON_Encoder** is a lightweight Arduino library designed to handle URL encoding and decoding for JSON strings. This library is particularly useful for IoT and microcontroller applications where JSON data must be transmitted over networks with URL-safe formatting.
## Features
- **URL Encoding**: Converts JSON strings into URL-encoded format for safe transmission.
- **URL Decoding**: Reconstructs JSON strings from URL-encoded strings.
- **Simple API**: Minimal and intuitive function calls for seamless integration.
- **Optimized for Arduino**: Lightweight and compatible with all Arduino-compatible boards.## Installation
### Using the Arduino Library Manager
1. Open the Arduino IDE.
2. Navigate to **Sketch** > **Include Library** > **Manage Libraries...**.
3. Search for `JSON_Encoder` and click **Install**.### Manual Installation
1. Download the library as a ZIP file from the [GitHub repository](https://github.com/styropyr0/JSON_Encoder).
2. Open the Arduino IDE.
3. Navigate to **Sketch** > **Include Library** > **Add .ZIP Library...**.
4. Select the downloaded ZIP file.## API Reference
### `encode(String jsonString)`
- **Description**: Converts a JSON string into a URL-encoded string.
- **Parameters**:
- `jsonString` (String): The input JSON string.
- **Returns**: A URL-encoded string.### `decode(String codedString)`
- **Description**: Converts a URL-encoded string back into a JSON string.
- **Parameters**:
- `codedString` (String): The URL-encoded input string.
- **Returns**: A JSON-formatted string.## Example Usage
### Encoding a JSON String
```cpp
#includevoid setup() {
Serial.begin(9600);
String json = "{\"temperature\":23.5,\"humidity\":45}";
String encoded = encode(json);
Serial.println("Encoded: " + encoded);
}void loop() {
// No loop actions needed
}
```### Decoding a URL-Encoded String
```cpp
#includevoid setup() {
Serial.begin(9600);
String encoded = "%7B%22temperature%22%3A23.5%2C%22humidity%22%3A45%7D";
String json = decode(encoded);
Serial.println("Decoded: " + json);
}void loop() {
// No loop actions needed
}
```### Sample Output
**Encoded**: `%7B%22temperature%22%3A23.5%2C%22humidity%22%3A45%7D`
**Decoded**: `{"temperature":23.5,"humidity":45}`## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
## License
This library is licensed under the [MIT License](LICENSE).
## Author
Developed by **Saurav Sajeev**.