package org.ut.cmldep.json.parser;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Iurii on 12/11/2014.
 */
public class InstancesToDelete {

    public List<String> getInstances() {
        return instancesToDelete;
    }

    public InstancesToDelete(JsonNode json) throws IOException {

        ObjectMapper mapper = new ObjectMapper();

        JsonNode arrNode = json.findValue("instances");
        if (arrNode.isArray()) {
            for (final JsonNode objNode : arrNode) {
                instancesToDelete.add(mapper.readValue(objNode, String.class));
                System.out.println(objNode);
            }
        }
    }

    private List<String> instancesToDelete = new ArrayList<String>();
}
