53 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Go
		
	
	
	
| /*
 | |
|  * Copyright 2025 coze-dev Authors
 | |
|  *
 | |
|  * Licensed under the Apache License, Version 2.0 (the "License");
 | |
|  * you may not use this file except in compliance with the License.
 | |
|  * You may obtain a copy of the License at
 | |
|  *
 | |
|  *     http://www.apache.org/licenses/LICENSE-2.0
 | |
|  *
 | |
|  * Unless required by applicable law or agreed to in writing, software
 | |
|  * distributed under the License is distributed on an "AS IS" BASIS,
 | |
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|  * See the License for the specific language governing permissions and
 | |
|  * limitations under the License.
 | |
|  */
 | |
| 
 | |
| package sonic
 | |
| 
 | |
| import "github.com/bytedance/sonic"
 | |
| 
 | |
| var config = sonic.Config{
 | |
| 	UseInt64: true,
 | |
| }.Froze()
 | |
| 
 | |
| // Marshal returns the JSON encoding bytes of v.
 | |
| func Marshal(val interface{}) ([]byte, error) {
 | |
| 	return config.Marshal(val)
 | |
| }
 | |
| 
 | |
| // MarshalIndent is like Marshal but applies Indent to format the output.
 | |
| // Each JSON element in the output will begin on a new line beginning with prefix
 | |
| // followed by one or more copies of indent according to the indentation nesting.
 | |
| func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
 | |
| 	return config.MarshalIndent(v, prefix, indent)
 | |
| }
 | |
| 
 | |
| // MarshalString returns the JSON encoding string of v.
 | |
| func MarshalString(val interface{}) (string, error) {
 | |
| 	return config.MarshalToString(val)
 | |
| }
 | |
| 
 | |
| // Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
 | |
| // NOTICE: This API copies given buffer by default,
 | |
| // if you want to pass JSON more efficiently, use UnmarshalString instead.
 | |
| func Unmarshal(buf []byte, val interface{}) error {
 | |
| 	return config.Unmarshal(buf, val)
 | |
| }
 | |
| 
 | |
| // UnmarshalString is like Unmarshal, except buf is a string.
 | |
| func UnmarshalString(buf string, val interface{}) error {
 | |
| 	return config.UnmarshalFromString(buf, val)
 | |
| }
 |