File: main.cpp

package info (click to toggle)
simdjson 4.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 31,400 kB
  • sloc: cpp: 195,760; ansic: 20,954; sh: 1,126; python: 885; makefile: 47; ruby: 25; javascript: 13
file content (22 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "mylib.h"
#include <simdjson.h>
#include <iostream>
#include <memory>

int main() {
    simdjson::padded_string json = R"([ 1, 2, 3, 4 ])"_padded;
    simdjson::padded_string minified = minify_json(json);
    std::cout << "Minified: " << std::string_view(minified) << std::endl;

    // Also directly use minify
    size_t length = json.size();
    std::unique_ptr<char[]> buffer{new char[length]};
    size_t new_length{};
    auto error = simdjson::minify(json.data(), length, buffer.get(), new_length);
    if (error) {
        std::cerr << "Error: " << simdjson::error_message(error) << std::endl;
    } else {
        std::cout << "Direct minified: " << std::string(buffer.get(), new_length) << std::endl;
    }
    return 0;
}