The gjson
module implements powerful data encoding/parsing functions, supporting data hierarchy retrieval, dynamic creation and modification of Json
objects, and features such as parsing and conversion of common data formats.
Features:
- Supports data hierarchy retrieval;
- Supports runtime data modification;
- Supports dynamic creation of hierarchical data structures and conversion to supported data formats;
- Supports conversion among
JSON
, XML
, INI
, YAML/YML
, TOML
, PROPERTIES
, Struct
data formats;
info
Note that the gjson
package supports reading, writing, and conversion of multiple data formats, not limited to the json
format.
Usage:
import "github.com/gogf/gf/v2/encoding/gjson"
API Documentation:
https://pkg.go.dev/github.com/gogf/gf/v2/encoding/gjson
Documentation
📄️ General Codec - CreationUsing the gjson module of the GoFrame framework to create JSON objects. Supports multiple data formats such as JSON and XML, and provides New and Load* methods for users to call. Demonstrates methods for creating JSON objects from JSON, XML, and struct objects with sample code to help developers understand and apply.
📄️ General Codec - Nested VisitingUsing gjson for hierarchical access in the GoFrame framework, accessing unknown data structures through flexible hierarchical separators. Includes setting custom separator characters and handling cases where key names themselves contain hierarchical symbols. Additionally, discusses the impact of modifying reference type variables in Go language and its effect on underlying data.
📄️ General Codec - StructUsing the Struct method in the GoFrame framework to convert JSON data into a specified data format or object. The example demonstrates how to parse JSON data and use the gjson library to scan it as a custom user struct. This type of data format conversion is very useful when dealing with complex data structures, especially in Go programming.
📄️ General Codec - Dynamic Creation and ModificationUsing gjson in the GoFrame framework for dynamic data creation and modification. gjson not only parses and retrieves unknown data structures flexibly but also dynamically creates and edits data content. Through specific examples, methods for setting data, creating arrays, and modifying JSON content are demonstrated, making the encoding and parsing of data structures more flexible and convenient.
📄️ General Codec - Data FormatData format conversion using the GoFrame framework, including mutual conversion among JSON, XML, YAML, TOML, and other formats, with an example code provided. Using the gjson library, the Must* methods can ensure safe data format conversion.
📄️ General Codec - MethodsVarious methods for general encoding and decoding using the GoFrame framework, including the creation of Json objects, data access, and format conversion. Provides detailed descriptions and code examples of methods such as New, Load, Encode, and Decode, helping to understand efficient data format handling in GoFrame.
📄️ General Codec - FAQThe potential issue of loss of large number precision when handling JSON data with the GoFrame framework, along with specific solution example code. By adjusting gjson options, precision loss can be avoided to ensure data accuracy. Additionally, related links are provided for further reference.