cesanta/frozen

Missing entry if key-name ends with dot

j-moeller opened this issue · 0 comments

Parsing and dumping a JSON object that contains a key which ends with a dot results in the respective entry missing from the output. I've build a minimal working sample to reproduce the behavior:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "frozen.h"

#define BUFFER_SIZE 8192

int run(const char* Data, size_t Size)
{
    char* json_buf = (char*)malloc(BUFFER_SIZE);
    if (NULL == json_buf) {
        return -1;
    }

    struct json_out out = JSON_OUT_BUF(json_buf, BUFFER_SIZE);
    if (0 > json_prettify(Data, Size, &out)) {
        free(json_buf);
        return -1;
    }

    printf("%s\n", json_buf);
    free(json_buf);

    return 0;
}

int main(int argc, char** argv) {
    run(argv[1], strlen(argv[1]));
}
clang -I ./frozen main.c frozen/frozen.c -o main
./main "{\"key\": 10, \"hidden.\": 20}"
Expected:
{
  "key": 10,
  "hidden.": 20
}

Actual:
{
  "key": 10
}