https://github.com/mehditeymorian/json
standard 'encoding/json' module with 'in' and 'out' options to have more control over decoding and encoding
https://github.com/mehditeymorian/json
encoder-decoder golang golang-module json
Last synced: 26 days ago
JSON representation
standard 'encoding/json' module with 'in' and 'out' options to have more control over decoding and encoding
- Host: GitHub
- URL: https://github.com/mehditeymorian/json
- Owner: mehditeymorian
- Created: 2023-01-20T12:16:58.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-20T12:51:56.000Z (over 3 years ago)
- Last Synced: 2025-10-18T16:54:40.647Z (8 months ago)
- Topics: encoder-decoder, golang, golang-module, json
- Language: Go
- Homepage:
- Size: 197 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Encoding Json
Golang standard `encoding/json` module with more options to have more control over encoding and decoding.
## Options
- `in`: used to include a field only in decoding
- `out`: used to include a field only in encoding
## Description
| example | description |
|--------------------|-------------------------------------------|
| json:"-" | field is ignored |
| json:"name" | field is included in `input` and `output` |
| json:"name,in" | field is only included in `input` |
| json:"name,out" | field is only included in `output` |
| json:"name,in,out" | field is included in `input` and `output` |
## Example
Considering the following struct as an example:
- included in decode(unmarshalling):
- name
- email
- password
- included in encode(marshalling):
- name
- email
- balance
```go
package main
type User struct {
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password,in"`
Balance uint `json:"balance,out"`
}
```
# Acknowledgment
This module is a copy of `encoding/json` module from Go version `1.19`.