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.
- 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.
- Open the Arduino IDE.
- Navigate to Sketch > Include Library > Manage Libraries....
- Search for
JSON_Encoder
and click Install.
- Download the library as a ZIP file from the GitHub repository.
- Open the Arduino IDE.
- Navigate to Sketch > Include Library > Add .ZIP Library....
- Select the downloaded ZIP file.
- Description: Converts a JSON string into a URL-encoded string.
- Parameters:
jsonString
(String): The input JSON string.
- Returns: A URL-encoded string.
- Description: Converts a URL-encoded string back into a JSON string.
- Parameters:
codedString
(String): The URL-encoded input string.
- Returns: A JSON-formatted string.
#include <JSON_Encoder.h>
void 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
}
#include <JSON_Encoder.h>
void 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
}
Encoded: %7B%22temperature%22%3A23.5%2C%22humidity%22%3A45%7D
Decoded: {"temperature":23.5,"humidity":45}
Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.
This library is licensed under the MIT License.
Developed by Saurav Sajeev.