summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/highlight/data_language_json.cpp
blob: 224a2630a02bc30134da423aa96a7e7bd35725ea (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
33
34
#include "data_language_json.h"

#include <library/cpp/json/json_reader.h>
#include <library/cpp/resource/resource.h>

namespace NSQLHighlight {

TVector<TString> LoadTypes() {
    TString resource = NResource::Find("types.json");
    NJson::TJsonValue json = NJson::ReadJsonFastTree(resource);

    TVector<TString> types;
    for (const NJson::TJsonValue& value : json.GetArraySafe()) {
        types.emplace_back(value["name"].GetStringSafe());
    }
    return types;
}

TVector<TString> LoadHints() {
    TString resource = NResource::Find("statements_opensource.json");
    NJson::TJsonValue json = NJson::ReadJsonFastTree(resource);

    TVector<TString> hints;
    for (const auto& [statement, services] : json.GetMapSafe()) {
        for (const auto& [service, kinds] : services.GetMapSafe()) {
            for (const auto& hint : kinds["hints"].GetArraySafe()) {
                hints.emplace_back(hint["name"].GetStringSafe());
            }
        }
    }
    return hints;
}

} // namespace NSQLHighlight