| 
									
										
										
										
											2020-08-27 09:49:42 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2021-03-26 15:24:19 +08:00
										 |  |  | Copyright 2021 The KubeVela Authors. | 
					
						
							| 
									
										
										
										
											2020-08-27 09:49:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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 utils | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 10:21:00 +08:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"bytes" | 
					
						
							|  |  |  | 	"encoding/json" | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2020-08-27 09:49:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // DumpJSON returns the JSON encoding
 | 
					
						
							|  |  |  | func DumpJSON(o interface{}) string { | 
					
						
							|  |  |  | 	j, _ := json.Marshal(o) | 
					
						
							|  |  |  | 	return string(j) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-03-07 10:21:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // StrictUnmarshal unmarshal target structure and disallow unknown fields
 | 
					
						
							|  |  |  | func StrictUnmarshal(bs []byte, dest interface{}) error { | 
					
						
							|  |  |  | 	d := json.NewDecoder(bytes.NewReader(bs)) | 
					
						
							|  |  |  | 	d.DisallowUnknownFields() | 
					
						
							|  |  |  | 	return d.Decode(dest) | 
					
						
							|  |  |  | } |