- JSONGO: Golang JSON Parser
Welcome to the JSONGO documentation! JSONGO is a JSON parsing library for the Go programming language that provides easy-to-use functions to parse JSON data into a structured format.
JSONGO aims to simplify JSON parsing in Go applications by offering a user-friendly API that allows you to parse JSON data from strings, byte slices, or rune slices into structured JSValue
objects. These objects can then be easily manipulated and queried to extract the necessary data.
- Multiple Input Formats: JSONGO supports parsing JSON data from strings, byte slices, and rune slices, giving you flexibility in handling different data sources.
- Structured Parsing: The library parses JSON data into a structured format represented by the
JSValue
struct, making it easy to navigate and extract data. - Data Extraction:
JSValue
provides methods to extract data of various types (string, int, float, bool, array, object) from the parsed JSON structure. - Error Handling: The library handles parsing errors gracefully, returning meaningful error messages to aid in debugging.
- Ease of Use: JSONGO's functions and methods are designed to be intuitive and straightforward.
jsongo/
|-- jsongo.go
|-- jsvalue.go
|-- LICENSE
|-- README.md
|-- .gitignore
|-- example/
| |-- main.go
|
|-- tests/
| |-- jsongo_test.go
|-- .gitignore
jsongo.go
: Contains the main parsing functions.jsvalue.go
: Defines theJSValue
struct and its methods.example
: Contains an example usage of JSONGO.tests
: Unit tests for the JSON parser.LICENSE
: The project's license information.README.md
: The main documentation file.
To use JSONGO in your project, use the go get
command:
go get github.com/sdwillbrand/jsongo
Here's a basic example of how to use JSONGO in your application:
package main
import (
"fmt"
"github.com/sdwillbrand/jsongo"
)
func main() {
jsonString := `{"name": "John", "age": 30, "city": "New York"}`
jsValue := jsongo.ParseFromString(jsonString)
if jsValue != nil {
fmt.Println(jsValue.String())
}
}
This function parses the provided JSON string and returns a pointer to a JSValue
struct representing the parsed JSON structure.
Parameters:
data string
: The JSON data as a string.
Returns:
*JSValue
: A pointer to the parsed JSON structure (JSValue
).
This function parses the provided JSON data as a byte slice and returns a pointer to a JSValue
struct representing the parsed JSON structure.
Parameters:
data []byte
: The JSON data as a byte slice.
Returns:
*JSValue
: A pointer to the parsed JSON structure (JSValue
).
This function parses the provided JSON data as a rune slice and returns a pointer to a JSValue
struct representing the parsed JSON structure.
Parameters:
data []rune
: The JSON data as a rune slice.
Returns:
*JSValue
: A pointer to the parsed JSON structure (JSValue
).
The JSValue
struct represents the parsed JSON structure. It provides various methods to extract data of different types from the JSON data.
This method returns the type of the JSON value represented by the JSValue
.
This method returns the JSON value as a string.
This method returns the JSON value as an integer.
This method returns the JSON value as a floating-point number.
This method returns the JSON value as a boolean.
This method returns the JSON value as an array of JSValue
pointers.
This method returns the JSON value as an object (map) of JSValue
pointers.
Contributions to JSONGO are welcome! If you encounter any bugs or have ideas for improvements, please follow the guidelines below.
If you find a bug or have a feature request, please open an issue on the project's GitHub repository. Provide as much detail as possible to help us understand and address the problem.
If you want to contribute code to JSONGO, follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the code passes all tests.
- Open a pull request, explaining the changes you've made.
We will review your pull request and provide feedback as needed.
JSONGO is licensed under the MIT License.
Feel free to explore, use, and contribute to the JSONGO project. Happy JSON parsing! 🚀