11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef INCLUDE_V8_JSON_H_
61cb0ef41Sopenharmony_ci#define INCLUDE_V8_JSON_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "v8-local-handle.h"  // NOLINT(build/include_directory)
91cb0ef41Sopenharmony_ci#include "v8config.h"         // NOLINT(build/include_directory)
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cinamespace v8 {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass Context;
141cb0ef41Sopenharmony_ciclass Value;
151cb0ef41Sopenharmony_ciclass String;
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci/**
181cb0ef41Sopenharmony_ci * A JSON Parser and Stringifier.
191cb0ef41Sopenharmony_ci */
201cb0ef41Sopenharmony_ciclass V8_EXPORT JSON {
211cb0ef41Sopenharmony_ci public:
221cb0ef41Sopenharmony_ci  /**
231cb0ef41Sopenharmony_ci   * Tries to parse the string |json_string| and returns it as value if
241cb0ef41Sopenharmony_ci   * successful.
251cb0ef41Sopenharmony_ci   *
261cb0ef41Sopenharmony_ci   * \param the context in which to parse and create the value.
271cb0ef41Sopenharmony_ci   * \param json_string The string to parse.
281cb0ef41Sopenharmony_ci   * \return The corresponding value if successfully parsed.
291cb0ef41Sopenharmony_ci   */
301cb0ef41Sopenharmony_ci  static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
311cb0ef41Sopenharmony_ci      Local<Context> context, Local<String> json_string);
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  /**
341cb0ef41Sopenharmony_ci   * Tries to stringify the JSON-serializable object |json_object| and returns
351cb0ef41Sopenharmony_ci   * it as string if successful.
361cb0ef41Sopenharmony_ci   *
371cb0ef41Sopenharmony_ci   * \param json_object The JSON-serializable object to stringify.
381cb0ef41Sopenharmony_ci   * \return The corresponding string if successfully stringified.
391cb0ef41Sopenharmony_ci   */
401cb0ef41Sopenharmony_ci  static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify(
411cb0ef41Sopenharmony_ci      Local<Context> context, Local<Value> json_object,
421cb0ef41Sopenharmony_ci      Local<String> gap = Local<String>());
431cb0ef41Sopenharmony_ci};
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci}  // namespace v8
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci#endif  // INCLUDE_V8_JSON_H_
48