Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Analyzing the json_value struct, I don't get why values, object_keys and length are fields outside the union. I expected something like:

  struct json_value {
    enum json_type type;
    union {
      bool boolean;
      char *string;
      double number;
      struct {
        char **keys;
        struct json_value *values;
        size_t length;
      } object;
    } value;
  };
Of course I would also use anonymous structs and unions to simplify

  json->value.object.length
to

  json->length


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: