package org.implab.gradle.common.json.dsl;

import org.gradle.api.Action;

public interface JsonObjectSpec {

    void set(String key, Object value);

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

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