summaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/jsonpath/jsonpath.cpp
blob: 0c7655791e65e0cec76f275b3867735f9cba49a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "jsonpath.h"

#include <yql/essentials/minikql/jsonpath/parser/binary.h>
#include "executor.h"

using namespace NYql;
using namespace NYql::NUdf;
using namespace NJson;

namespace NYql::NJsonPath {

TResult ExecuteJsonPath(
    const TJsonPathPtr jsonPath,
    const TValue& json,
    const TVariablesMap& variables,
    const NUdf::IValueBuilder* valueBuilder) {
    TExecutor executor(jsonPath, {json}, variables, valueBuilder);
    return executor.Execute();
}

TVariablesMap DictToVariables(const NUdf::TUnboxedValue& dict) {
    TVariablesMap variables;
    TUnboxedValue key;
    TUnboxedValue payload;
    auto it = dict.GetDictIterator();
    while (it.NextPair(key, payload)) {
        variables[key.AsStringRef()] = TValue(payload);
    }
    return variables;
}

} // namespace NYql::NJsonPath