Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify JSONWriter.write* methods to take name + value #3

Open
shaie opened this issue May 21, 2013 · 1 comment
Open

Modify JSONWriter.write* methods to take name + value #3

shaie opened this issue May 21, 2013 · 1 comment

Comments

@shaie
Copy link
Contributor

shaie commented May 21, 2013

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
Copy link
Contributor Author

shaie commented May 21, 2013

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant