bytedance / sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
Apache License 2.0
835 stars 101 forks source link

Add more examples for Document API #67

Open liuq19 opened 1 year ago

liuq19 commented 1 year ago

We need to add more examples for Document API into example directory

The example should be like follows:

#include <iostream>
#include <string>

#include "sonic/sonic.h"

int main() {
  using NodeType = sonic_json::Node;
  using Allocator = typename NodeType::AllocatorType;
  sonic_json::Node node;
  Allocator alloc;

  node.SetObject();
  node.AddMember("Key", NodeType("Value", alloc), alloc);
  std::cout << "Add member successfully!\n";
  return 0;
}
// g++ -I../include/ -march=haswell --std=c++11 get_and_set.cpp -o get_and_set