Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodedStringFromJSON ¶
DecodedStringFromJSON decodes a string from JSON, returning the decoded string and the remainder byte slice of the original buffer. On error, the returned byte slice points to the first byte that caused the error indicated.
func ExampleDecode() { decoded, remainder, err := goejs.DecodedStringFromJSON([]byte("\"\\u0001\\u2318 a\" some extra bytes after final quote")) if err != nil { fmt.Println(err) } if actual, expected := string(remainder), " some extra bytes after final quote"; actual != expected { fmt.Printf("Remainder Actual: %#q; Expected: %#q\n", actual, expected) } fmt.Printf("%v", decoded) // Output: �⌘ a }
func EncodedJSONFromString ¶
EncodedJSONFromString appends the JSON encoding of the provided string to the provided byte slice, and returns the modified byte slice.
func ExampleEncode() { encoded := goejs.EncodedJSONFromString([]byte("prefix:"), "�⌘ a") fmt.Printf("%s", encoded) // Output: prefix:"\u0001\u2318 a" }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.