|
|
|||
File indexing completed on 2026-09-19 09:26:05
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 <optional> 0009 0010 #include "v8-local-handle.h" // NOLINT(build/include_directory) 0011 #include "v8-message.h" // NOLINT(build/include_directory) 0012 #include "v8config.h" // NOLINT(build/include_directory) 0013 0014 namespace v8 { 0015 0016 class Context; 0017 class Value; 0018 class String; 0019 0020 /** 0021 * A JSON Parser and Stringifier. 0022 */ 0023 class V8_EXPORT JSON { 0024 public: 0025 /** 0026 * Tries to parse the string |json_string| and returns it as value if 0027 * successful. 0028 * 0029 * \param the context in which to parse and create the value. 0030 * \param json_string The string to parse. 0031 * \param origin Optional script origin to use for error reporting. 0032 * If not provided, error reporting will use default origin options 0033 * or attempt to infer origin from the current stack. 0034 * \return The corresponding value if successfully parsed. 0035 */ 0036 static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse( 0037 Local<Context> context, Local<String> json_string, 0038 std::optional<ScriptOrigin> origin = std::nullopt); 0039 0040 /** 0041 * Tries to stringify the JSON-serializable object |json_object| and returns 0042 * it as string if successful. 0043 * 0044 * \param json_object The JSON-serializable object to stringify. 0045 * \return The corresponding string if successfully stringified. 0046 */ 0047 static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify( 0048 Local<Context> context, Local<Value> json_object, 0049 Local<String> gap = Local<String>()); 0050 }; 0051 0052 } // namespace v8 0053 0054 #endif // INCLUDE_V8_JSON_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|