jgo

package module
v0.0.0-...-8d8e2d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 7 Imported by: 0

README ΒΆ

Jgo : Generic JSON parsing library

logo

Build CI Go Report Card PkgGoDev

πŸ“” Generic JSON parser library. Used to marshall .json to generic structures and be able to unmarshall them.

This project is under active development, there may be bugs or missing features. If you have any problem or would like to see a feature implemented, please, open an issue. This is essential so that we can continue to improve it!


Table of Contents

Presentation

Features

Getting Started

From release

From sources

🀝 Contributing

Contributions are greatly appreciated!

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some amazing stuff')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Create a new Pull Request

Issues and feature requests are welcome! Feel free to check issues page.

Author

πŸ‘€ Hugo Bollon

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

This project is under MIT license.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type JSONArray ΒΆ

type JSONArray struct {
	Values []JSONEntity
}

func UnmarshalJSONArrayFromString ΒΆ

func UnmarshalJSONArrayFromString(input string) (JSONArray, error)

func UnmarshalJSONArrayFromTokenizer ΒΆ

func UnmarshalJSONArrayFromTokenizer(t *JSONTokenizer) (JSONArray, error)

func (*JSONArray) Print ΒΆ

func (arr *JSONArray) Print()

func (*JSONArray) Put ΒΆ

func (arr *JSONArray) Put(value JSONEntity) error

func (*JSONArray) String ΒΆ

func (arr *JSONArray) String(depth int) string

type JSONEntity ΒΆ

type JSONEntity interface {
	Print()
	String(int) string
}

type JSONObject ΒΆ

type JSONObject struct {
	Values map[string]JSONEntity
}

func Unmarshal ΒΆ

func Unmarshal(input any) (JSONObject, error)

func UnmarshalFromGenericMap ΒΆ

func UnmarshalFromGenericMap(input map[string]any) JSONObject

func UnmarshalFromMap ΒΆ

func UnmarshalFromMap(input map[string]JSONEntity) JSONObject

func UnmarshalFromString ΒΆ

func UnmarshalFromString(input string) (JSONObject, error)

func UnmarshalFromTokenizer ΒΆ

func UnmarshalFromTokenizer(t *JSONTokenizer) (JSONObject, error)

func (*JSONObject) Get ΒΆ

func (obj *JSONObject) Get(key string) JSONEntity

func (*JSONObject) Print ΒΆ

func (obj *JSONObject) Print()

func (*JSONObject) Put ΒΆ

func (obj *JSONObject) Put(key string, value JSONEntity) error

func (*JSONObject) String ΒΆ

func (obj *JSONObject) String(depth int) string

type JSONTokenizer ΒΆ

type JSONTokenizer struct {
	// CurrentCharacterPosition is the current read character position on the current line.
	CurrentCharacterPosition int64
	// Eof indicate if the end of the input has been found.
	Eof bool
	// Index indicate the current read index of the input.
	Index int64
	// Line indicate the current line of the input.
	Line int64
	// Previous is the previous character read from the input.
	Previous rune
	// Reader for the input.
	Reader *bufio.Reader
	// UsePrevious is a flag to indicate that a previous character was requested.
	UsePrevious bool
	// CharactersPreviousLine is the number of characters read in the previous line.
	CharactersPreviousLine int64
}

func NewJSONTokenizer ΒΆ

func NewJSONTokenizer(input string) *JSONTokenizer

func (*JSONTokenizer) Back ΒΆ

func (t *JSONTokenizer) Back() error

Back allow the tokenizer to go back one character. If the tokenizer is at the beginning of the input or if the tokenizr is already set to use the previous character, an error is returned.

func (*JSONTokenizer) Next ΒΆ

func (t *JSONTokenizer) Next() (rune, error)

Next returns the next character from the input. If the end of the input is reached, EOF is returned.

func (*JSONTokenizer) NextCharacter ΒΆ

func (t *JSONTokenizer) NextCharacter() (rune, error)

NextCharacter returns the next character from the input excluding whitespaces.

func (*JSONTokenizer) NextString ΒΆ

func (t *JSONTokenizer) NextString() (string, error)

func (*JSONTokenizer) NextValue ΒΆ

func (t *JSONTokenizer) NextValue() (JSONEntity, error)

func (*JSONTokenizer) Peek ΒΆ

func (t *JSONTokenizer) Peek() (rune, error)

Peek returns the next character from the input without advancing the tokenizer.

type JSONValue ΒΆ

type JSONValue struct {
	JSONValueType
}

func CreateJSONValue ΒΆ

func CreateJSONValue(value any) JSONValue

func CreateJSONValueFromString ΒΆ

func CreateJSONValueFromString(value string) JSONValue

func (*JSONValue) Print ΒΆ

func (obj *JSONValue) Print()

func (*JSONValue) Set ΒΆ

func (obj *JSONValue) Set(value JSONValueType) error

func (*JSONValue) String ΒΆ

func (obj *JSONValue) String(_ int) string

type JSONValueType ΒΆ

type JSONValueType interface {
	// contains filtered or unexported methods
}

Directories ΒΆ

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL