Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sjson: clean up documentation grammar #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions sjson.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package sjson provides setting json values.
// Package sjson provides a very fast and simple way to set JSON values.
package sjson

import (
Expand Down Expand Up @@ -427,26 +427,25 @@ func isOptimisticPath(path string) bool {
//
// A path is a series of keys separated by a dot.
//
// {
// "name": {"first": "Tom", "last": "Anderson"},
// "age":37,
// "children": ["Sara","Alex","Jack"],
// "friends": [
// {"first": "James", "last": "Murphy"},
// {"first": "Roger", "last": "Craig"}
// ]
// }
// "name.last" >> "Anderson"
// "age" >> 37
// "children.1" >> "Alex"
//
// {
// "name": {"first": "Tom", "last": "Anderson"},
// "age":37,
// "children": ["Sara","Alex","Jack"],
// "friends": [
// {"first": "James", "last": "Murphy"},
// {"first": "Roger", "last": "Craig"}
// ]
// }
// "name.last" >> "Anderson"
// "age" >> 37
// "children.1" >> "Alex"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor automatically did this. Here is how it looks with the updated changes.
Monosnap sjson - Go Documentation Server 2024-04-09 21-05-16

func Set(json, path string, value interface{}) (string, error) {
return SetOptions(json, path, value, nil)
}

// SetBytes sets a json value for the specified path.
// If working with bytes, this method preferred over
// Set(string(data), path, value)
// SetBytes sets a json value for the specified path and returns the updated
// JSON. If working with bytes, this method is preferred over Set(string(data),
// path, value).
func SetBytes(json []byte, path string, value interface{}) ([]byte, error) {
return SetBytesOptions(json, path, value, nil)
}
Expand All @@ -473,8 +472,9 @@ func SetRawOptions(json, path, value string, opts *Options) (string, error) {
return string(res), err
}

// SetRawBytes sets a raw json value for the specified path.
// If working with bytes, this method preferred over
// SetRawBytes sets a raw json value for the specified path and returns the
// updated JSON.
// If working with bytes, this method is preferred over
// SetRaw(string(data), path, value)
func SetRawBytes(json []byte, path string, value []byte) ([]byte, error) {
return SetRawBytesOptions(json, path, value, nil)
Expand Down Expand Up @@ -646,8 +646,9 @@ func SetOptions(json, path string, value interface{},
return string(res), err
}

// SetBytesOptions sets a json value for the specified path with options.
// If working with bytes, this method preferred over
// SetBytesOptions sets a json value for the specified path with options and
// returns the updated JSON.
// If working with bytes, this method is preferred over
// SetOptions(string(data), path, value)
func SetBytesOptions(json []byte, path string, value interface{},
opts *Options) ([]byte, error) {
Expand Down Expand Up @@ -717,8 +718,9 @@ func SetBytesOptions(json []byte, path string, value interface{},
return res, err
}

// SetRawBytesOptions sets a raw json value for the specified path with options.
// If working with bytes, this method preferred over
// SetRawBytesOptions sets a raw json value for the specified path with options
// and returns the updated JSON.
// If working with bytes, this method is preferred over
// SetRawOptions(string(data), path, value, opts)
func SetRawBytesOptions(json []byte, path string, value []byte,
opts *Options) ([]byte, error) {
Expand Down