stdx.data.json.parser.readObject issues a callback for each key in an object. The type for the callback is scope void delegate(string key) @safe del).
For my use case it would be sufficient to get the raw key string, e.g. use a delegate with type void delegate(JSONString!String key) to safe on allocations and unescaping the string. The next best solution would be to avoid string and get a const(char)[] as a key. Currently I cannot do this:
Error: delegate del(string key) is not callable using argument types (const(char)[])
Looking at the code, a possible work around would be.
cast the input to immutable (although it isn't)
use string throughout, the lexing code will not allocate if the input is immutable and does not need unescaping
be careful to cast everything back / correctly handle the immutable values that aren't.
It will still check if the keys are escaped, although I don't need that. Thinking about it, maybe it's enough to change the signature to void delegate(String key) and also provide a slice if the buffer is not immutable, but const.
stdx.data.json.parser.readObject
issues a callback for each key in an object. The type for the callback isscope void delegate(string key) @safe del)
.For my use case it would be sufficient to get the raw key string, e.g. use a delegate with type
void delegate(JSONString!String key)
to safe on allocations and unescaping the string. The next best solution would be to avoid string and get aconst(char)[]
as a key. Currently I cannot do this:Looking at the code, a possible work around would be.
It will still check if the keys are escaped, although I don't need that. Thinking about it, maybe it's enough to change the signature to
void delegate(String key)
and also provide a slice if the buffer is not immutable, but const.What do you think?