import { writeBinary } from './binary.js';
import { ModifyError } from './ModifyRes.js';
export function writeJson(value, ctx, schema, t, parentId, modifyOp) {
    try {
        if (value === null) {
            return writeBinary(null, ctx, schema, t, parentId, modifyOp);
        }
        else {
            if (!t.validation(value, t)) {
                return new ModifyError(t, value);
            }
            return writeBinary(JSON.stringify(value), ctx, schema, t, parentId, modifyOp);
        }
    }
    catch (err) {
        return new ModifyError(t, value);
    }
}
//# sourceMappingURL=json.js.map