Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

string length feature #80

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
- NOTE: any references to yajl_val->u.string must be changed to
  yajl_val->u.string.s in existing code (should be minimal)

- use YAJL_GET_STRINGLEN(v) macro to get (size_t)length

This allows one to use the macros for strings with embedded binary 0s.

ari edelkind Support for tracking and getting the string len
    - NOTE: any references to yajl_val->u.string must be changed to
      yajl_val->u.string.s

    - use YAJL_GET_STRINGLEN(v) macro to get (size_t)length
3f9cedc
Owner

lloyd commented Jan 29, 2013

I like this change, but it's API breaking. it would require a 3.x version of yajl.

It's been many months since I looked at this, but IIRC, I was under the impression that the API was intended to be accessed by the macros, and the underlying yajl_val structure was to be considered opaque. Assuming that this is correct, it shouldn't break the API at all, and it also shouldn't break binary compatibility: since u.string.s is first in the yajl_val structure, it will be equivalent to (char*)u.string.

If the yajl_val structure is intended to be API-accessible, then u.string can be kept as (char*), and another structure can be added to the union (e.g. u.stringx) to track length. Then, u.string will be equivalent to u.stringx.s, and existing code that uses yajl_val->u.string will not break.

zimmerle commented Aug 5, 2015

+1 for this. My strings contains '\0'.

Don't ask why :)

Strings with embedded binary '\0's violate the JSON standard and it would be expected that other parsers would choke on them. You probably want Binary JSON (BSON) at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment