#include "JsonLogic.h"

#ifdef ARDUINO
#include <Arduino.h>
#else
#include <iostream>
#endif

namespace json_logic
{
    Json JsonLogic::operation_misc_log(JsonArrayView values, JsonView data) const
    {
        if (values.size() != 1)
            return Fail(__FUNCTION__, "Expected 1 argument, but received " +
                                          std::to_string(values.size()));
        Json result = ApplyInternal(values[0], data);
        if (HasError()) return Json{};
#ifdef ARDUINO
        ArduinoJson::serializeJson(result, Serial);
        Serial.println();
#else
        ArduinoJson::serializeJson(result, std::cout);
        std::cout << '\n';
#endif
        return result;
    }
}
