package org.implab.gradle.common.json;

import org.gradle.api.Action;

public interface JsonArraySpec {

    void add(Object value);

    default void obj(Action<? super JsonObjectSpec> action) {
        DefaultJsonObjectSpec child = new DefaultJsonObjectSpec();
        action.execute(child);
        add(child.toMap());
    }

    default void arr(Action<? super JsonArraySpec> action) {
        DefaultJsonArraySpec child = new DefaultJsonArraySpec();
        action.execute(child);
        add(child.toList());
    }
}