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

Export JSONObject with stapler throw NotExportableException exception when there is a field with null value. #172

Open
aHenryJard opened this issue Oct 1, 2019 · 2 comments

Comments

@aHenryJard
Copy link
Contributor

aHenryJard commented Oct 1, 2019

Using JSONObject in classes with annotation @ExportedBean works fine except when there is a field with null value.

Having a field with null value is correct in JSON format. So JSONObject with JSONNull should be exportable as other JSONObject.

The exception raised is:

org.kohsuke.stapler.export.NotExportableException: class net.sf.json.JSONNull doesn't have @ExportedBean

	at org.kohsuke.stapler.export.Property.writeValue(Property.java:298)
	at org.kohsuke.stapler.export.Property.writeValue(Property.java:168)
	at org.kohsuke.stapler.export.Property.writeValue(Property.java:266)
	at org.kohsuke.stapler.export.Property.writeValue(Property.java:168)
	at org.kohsuke.stapler.export.Property.writeTo(Property.java:153)
	at org.kohsuke.stapler.export.Model.writeNestedObjectTo(Model.java:223)
	at org.kohsuke.stapler.export.Model.writeTo(Model.java:194)
	at org.kohsuke.stapler.export.Model.writeTo(Model.java:214)
	at org.kohsuke.stapler.export.Model.writeTo(Model.java:182)

PR with test to reproduce the issue: #173

@batmat
Copy link
Member

batmat commented Nov 29, 2021

Done with #173 I assume?

@timja
Copy link
Member

timja commented Nov 29, 2021

There's a test case added now that reproduces the issue @batmat

It's ignored as the issue wasn't fixed:
https://github.com/stapler/stapler/blob/master/core/src/test/java/org/kohsuke/stapler/export/JSONDataWriterTest.java#L105

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

3 participants