Coverage Report

Created: 2025-07-11 06:27

/src/jsonnet/core/json.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
Copyright 2015 Google Inc. All rights reserved.
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
    http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
#ifndef JSONNET_JSON_H
18
#define JSONNET_JSON_H
19
20
#include <memory>
21
#include <string>
22
#include <vector>
23
24
#include <libjsonnet.h>
25
26
struct JsonnetJsonValue {
27
    enum Kind {
28
        ARRAY,
29
        BOOL,
30
        NULL_KIND,
31
        NUMBER,
32
        OBJECT,
33
        STRING,
34
    };
35
36
0
    JsonnetJsonValue() = default;
37
    JsonnetJsonValue(JsonnetJsonValue&) = delete;
38
0
    JsonnetJsonValue(JsonnetJsonValue&&) = default;
39
40
    JsonnetJsonValue(Kind kind, std::string string, double number)
41
0
        : kind(kind), string(string), number(number)
42
0
    {
43
0
    }
44
45
    Kind kind;
46
    std::string string;
47
    double number;  // Also used for bool (0.0 and 1.0)
48
    std::vector<std::unique_ptr<JsonnetJsonValue>> elements;
49
    std::map<std::string, std::unique_ptr<JsonnetJsonValue>> fields;
50
};
51
52
#endif