Java JacksonFeatureSet-class And Method Code Example

Here is an example of how to use the JacksonFeatureSet class from the package in Java:

import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;


public class Main {
    public static void main(String[] args) throws Exception {
        String json = "{\"name\":\"John\",\"age\":30}";

        JsonFactory jsonFactory = new JsonFactory();
        JsonParser jsonParser = jsonFactory.createJsonParser(new StringReader(json));

        JacksonFeatureSet featureSet = new JacksonFeatureSet(jsonParser);
        // Enable Feature

        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String fieldname = jsonParser.getCurrentName();
            if ("name".equals(fieldname)) {
            if ("age".equals(fieldname)) {

In this example, we create a JsonFactory object, JsonParser object and a JacksonFeatureSet object which wraps the JsonParser object. We then enable the ALLOW_COMMENTS feature using the enable() method, which allows parsing of JSON text containing comments. Finally, we use the JsonParser object to parse the JSON text and print the values of the "name" and "age" fields.

Please note that this class has been removed from library, it was present in version 2.6, But as of latest version it has been removed, you can use other libraries like Jackson library's JsonParser to achieve similar functionality.