noggit icon indicating copy to clipboard operation
noggit copied to clipboard

Modify JSONWriter.write* methods to take name + value

Open shaie opened this issue 11 years ago • 1 comments

I am using Noggit to serialize stuff into JSON using JSONWriter. My code generally looks like:

{code} writer.writer(name); writer.writeNameSeparator(); writer.write(value); {code}

If all write* methods took {{String name}} and {{TYPE value}}, where TYPE is the type each method takes, e.g. {{write(String name, long value)}}, it would generate much less code.

Similarly, I'd like to add startObject/Array variants which take a name for convenience.

shaie avatar May 21 '13 13:05 shaie

This is not so simple after all because the write methods are used by e.g. their counterpart write(TYPE[]). So there are few options:

  1. Add name to the signature, but don't write it if it's null. That way, e.g. write(boolean[]) can pass null for each write(b) it calls.

  2. Add additional write(name, value) methods

Any preferences?

shaie avatar May 21 '13 13:05 shaie