classgraph: Exception when deserializing from JSON

When deserializing from JSON, we get the following exception:

Exception in thread "main" java.lang.IllegalArgumentException: Expected integer; got java.lang.Long
	at nonapi.io.github.classgraph.json.JSONDeserializer.jsonBasicValueToObject(JSONDeserializer.java:112)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:479)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:602)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:602)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:602)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:602)
	at nonapi.io.github.classgraph.json.JSONDeserializer.populateObjectFromJsonObject(JSONDeserializer.java:602)
	at nonapi.io.github.classgraph.json.JSONDeserializer.deserializeObject(JSONDeserializer.java:681)
	at nonapi.io.github.classgraph.json.JSONDeserializer.deserializeObject(JSONDeserializer.java:708)
	at io.github.classgraph.ScanResult.fromJSON(ScanResult.java:1300)
	at classgraphjsonbug.Main.main(Main.java:9)

Even a simple program throws this exception:

package classgraphjsonbug;

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;

public class Main {
    public static void main(String[] args) {
        String json = scan();
        ScanResult scanResult = ScanResult.fromJSON(json);
    }

    private static String scan() {
        try (ScanResult scan = new ClassGraph()
                .verbose()
                .enableAllInfo()
                .scan()) {
            return scan.toJSON();
        }
    }
}

We’ve tested this code with the latest version 4.8.80 on the classpath. We have also attached the verbose output:

classgraph-json-bug.txt

Can you tell us what we’re doing wrong?

– Poke

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks! Fixed in 4.8.81.

I think you are the first users who tried to use the serialization / deserialization support 😃