w0rp / dson Goto Github PK
View Code? Open in Web Editor NEWA D JSON library
A D JSON library
Hi,
I've found a little bug with float handling.
Try :
auto objet = jsonObject();
objet["valeur"] = 1.001;
writeln(objet); // shows 1.001
auto objet2 = parseJSON(toJSON(object));
writeln(objet2); // shows 1.1
this could be corrected with something like :
JSON parseNumber() {
enum byte NEGATIVE = 1;
enum byte EXP_NEGATIVE = 2;
long integer = 0;
long remainder = 0;
short exponent = 0;
byte signInfo = 0;
int tailleReste = -1;
// Accumulate digits reading left-to-right in a number.
void parseDigits(T)(ref T accum) {
while (!empty()) {
switch(front()) {
case '0': .. case '9':
accum = cast(T) (accum * 10 + (moveFront() - '0'));
tailleReste++;
if (accum < 0) {
throw complaint("overflow error!");
}
break;
default:
return;
}
}
}
...
if (remainder != 0) {
// Add in the remainder.
if (whole==0) {
tailleReste++;
}
whole += remainder / (10.0 ^^ tailleReste);
}
It looks like there is some use of this module, so it would be good to set a version for this library, and set up some DUB package configuration so you can install it with DUB.
Hi,
I don't know if it's a bug, or if i have done something wrong.
I've try the following code :
auto objet = jsonObject();
objet["valeur"] = "é".toUpper();
writeln(objet);
auto js = toJSON(objet);
writeln(js);
auto objet2 = parseJSON(js);
writeln(objet2);
and it gives me :
["valeur":É]
{"valeur":"�\u0089"}
["valeur":�]
It seems the É isn't properly converted.
There is no trouble with lowercase accentuated letters, only with uppercase accentuated letters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.