Skip to content

Missing entry if key-name ends with dot #74

@j-moeller

Description

@j-moeller

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions