noggit
noggit copied to clipboard
Modify JSONWriter.write* methods to take name + value
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.
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:
-
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.
-
Add additional write(name, value) methods
Any preferences?