Store parsed token as string and allow conversion between various types (issues #64, #69, #90, #93)

This commit is contained in:
Benoit Blanchon
2015-08-10 17:22:22 +02:00
parent bce101578d
commit ef2641b49b
29 changed files with 686 additions and 274 deletions

31
src/Arduino/String.cpp Normal file
View File

@ -0,0 +1,31 @@
// Copyright Benoit Blanchon 2014-2015
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#ifndef ARDUINO
#include "../../include/ArduinoJson/Arduino/String.hpp"
#include <stdio.h> // for sprintf()
String::String(double value, unsigned char digits) {
char tmp[32];
sprintf(tmp, "%.*f", digits, value);
*this = tmp;
}
String::String(int value) {
char tmp[32];
sprintf(tmp, "%d", value);
*this = tmp;
}
String::String(long value) {
char tmp[32];
sprintf(tmp, "%ld", value);
*this = tmp;
}
#endif