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

Error in JsonWriter.formatJson() for enum #157

Closed
xeronix opened this issue Dec 22, 2021 · 2 comments
Closed

Error in JsonWriter.formatJson() for enum #157

xeronix opened this issue Dec 22, 2021 · 2 comments

Comments

@xeronix
Copy link

xeronix commented Dec 22, 2021

public class TestClass {
    private int a;
    private TestEnum enumObj;
    
    public TestClass() {
        a = 10;
        enumObj = TestEnum.GREEN;
    }
}
public enum TestEnum {
    GREEN;
}

Following code fails:

TestClass obj = new TestClass();
String objStr = JsonWriter.objectToJson(obj);
JsonWriter.formatJson(objStr)

Exception in thread "main" com.cedarsoftware.util.io.JsonIoException: Class 'com.ifn.dev.TestEnum' does not have primitive wrapper.

If i pass the pretty print argument then it works fine:

Map<String, Object> jsonWriterArgs = new HashMap<>();
jsonWriterArgs.put(JsonWriter.PRETTY_PRINT, true);      
String objStr = JsonWriter.objectToJson(obj);

I am using JDK 8.

@xeronix xeronix changed the title Error in JsonWriter.formatJson for enum Error in JsonWriter.formatJson() for enum Dec 22, 2021
@jdereg
Copy link
Owner

jdereg commented Oct 14, 2022

json-io 4.14.0 has been released. Fixes for enum handling and support for JDK's through 17 are included. Please let me know if this is an issue for you.

@jdereg
Copy link
Owner

jdereg commented Oct 13, 2023

json-io 4.14.2 fixes EnumSet.

@jdereg jdereg closed this as completed Oct 13, 2023
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

2 participants