Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:05:24

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_V8_JSON_H_
0006 #define INCLUDE_V8_JSON_H_
0007 
0008 #include "v8-local-handle.h"  // NOLINT(build/include_directory)
0009 #include "v8config.h"         // NOLINT(build/include_directory)
0010 
0011 namespace v8 {
0012 
0013 class Context;
0014 class Value;
0015 class String;
0016 
0017 /**
0018  * A JSON Parser and Stringifier.
0019  */
0020 class V8_EXPORT JSON {
0021  public:
0022   /**
0023    * Tries to parse the string |json_string| and returns it as value if
0024    * successful.
0025    *
0026    * \param the context in which to parse and create the value.
0027    * \param json_string The string to parse.
0028    * \return The corresponding value if successfully parsed.
0029    */
0030   static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse(
0031       Local<Context> context, Local<String> json_string);
0032 
0033   /**
0034    * Tries to stringify the JSON-serializable object |json_object| and returns
0035    * it as string if successful.
0036    *
0037    * \param json_object The JSON-serializable object to stringify.
0038    * \return The corresponding string if successfully stringified.
0039    */
0040   static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify(
0041       Local<Context> context, Local<Value> json_object,
0042       Local<String> gap = Local<String>());
0043 };
0044 
0045 }  // namespace v8
0046 
0047 #endif  // INCLUDE_V8_JSON_H_