Skip to content

Commit

Permalink
std/encoding/json: refactor documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 17, 2025
1 parent 8c38647 commit 6a11f73
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
60 changes: 30 additions & 30 deletions std/encoding/json/decode.jule
Original file line number Diff line number Diff line change
Expand Up @@ -625,44 +625,44 @@ impl jsonDecoder {
// Implementation supports only Jule types, excluding binded types.
//
// Decoding details:
// Since this function designed for comptime type analysis, the type [T] should
// be valid type for comptime. The type [any], which is stores dynamic type, is not valid.
// Any unsupported type causes exceptional with [DecodeError.UnsupportedType].
// Any incompatible value for type, invalid literal or something else causes
// exceptional with [DecodeError.UnsupportedType].
// Since this function designed for comptime type analysis, the type [T] should
// be valid type for comptime. The type [any], which is stores dynamic type, is not valid.
// Any unsupported type causes exceptional with [DecodeError.UnsupportedType].
// Any incompatible value for type, invalid literal or something else causes
// exceptional with [DecodeError.UnsupportedType].
//
// Signed/Unsigned Integers, Floating-Points:
// Decode as JSON numbers.
// Signed/Unsigned Integers, Floating-Points:
// Decode as JSON numbers.
//
// Booleans:
// Decode as JSON booleans.
// Booleans:
// Decode as JSON booleans.
//
// Strings:
// Decode as JSON strings. Invalid UTF-8 or invalid UTF-16 surrogate pairs
// are not treated as an exception. Instead, they are replaced by the
// Unicode replacement character U+FFFD.
// Strings:
// Decode as JSON strings. Invalid UTF-8 or invalid UTF-16 surrogate pairs
// are not treated as an exception. Instead, they are replaced by the
// Unicode replacement character U+FFFD.
//
// Structs:
// Decode as JSON objects with only public fields of struct.
// Structs:
// Decode as JSON objects with only public fields of struct.
//
// Arrays:
// Decode as JSON array.
// If array size is larger than JSON array, algorithm will change the
// remain data to zero-value for data-type.
// Arrays:
// Decode as JSON array.
// If array size is larger than JSON array, algorithm will change the
// remain data to zero-value for data-type.
//
// Slices:
// Decode as JSON array.
// For the []byte type, decodes strings as a base64-encoded string if the input
// is string, otherwise decodes as JSON array.
// Slices:
// Decode as JSON array.
// For the []byte type, decodes strings as a base64-encoded string if the input
// is string, otherwise decodes as JSON array.
//
// Maps:
// Decode as JSON object.
// Map's key type only can be: signed integer, unsigned integer and string.
// Other types will cause exceptional with [DecodeError.UnsupportedType].
// Maps:
// Decode as JSON object.
// Map's key type only can be: signed integer, unsigned integer and string.
// Other types will cause exceptional with [DecodeError.UnsupportedType].
//
// Smart Pointers:
// If smart pointer is nil, will be allocated by the algorithm for decoding.
// Otherwise, will decode into dereferenced value.
// Smart Pointers:
// If smart pointer is nil, will be allocated by the algorithm for decoding.
// Otherwise, will decode into dereferenced value.
//
// Too many nested types are not specifically checked and may cause too many
// recursive function calls, resulting in a crash at runtime. As a result of the tests,
Expand Down
62 changes: 31 additions & 31 deletions std/encoding/json/encode.jule
Original file line number Diff line number Diff line change
Expand Up @@ -447,45 +447,45 @@ fn encoder(): jsonEncoder {
// Implementation supports only Jule types, excluding binded types.
//
// Encoding details:
// Since this function designed for comptime type analysis, the type [T] should
// be valid type for comptime. The type [any], which is stores dynamic type, is not valid.
// Any unsupported type causes exceptional with [EncodeError.UnsupportedType].
// Since this function designed for comptime type analysis, the type [T] should
// be valid type for comptime. The type [any], which is stores dynamic type, is not valid.
// Any unsupported type causes exceptional with [EncodeError.UnsupportedType].
//
// Signed/Unsigned Integers, Floating-Points:
// Encode as JSON numbers.
// For floating-points, NaN or ±Inf will cause exceptional with [EncodeError.UnsupportedFloatValue].
// Signed/Unsigned Integers, Floating-Points:
// Encode as JSON numbers.
// For floating-points, NaN or ±Inf will cause exceptional with [EncodeError.UnsupportedFloatValue].
//
// Booleans:
// Encode as JSON booleans.
// Booleans:
// Encode as JSON booleans.
//
// Strings:
// Encode as JSON strings coerced to valid UTF-8, replacing invalid bytes
// with the Unicode replacement rune. So that the JSON will be safe to embed
// inside HTML <script> tags, the string is encoded using [HTMLEscape],
// which replaces "<", ">", "&", U+2028, and U+2029 are escaped
// to "\u003c", "\u003e", "\u0026", "\u2028", and "\u2029".
// Strings:
// Encode as JSON strings coerced to valid UTF-8, replacing invalid bytes
// with the Unicode replacement rune. So that the JSON will be safe to embed
// inside HTML <script> tags, the string is encoded using [HTMLEscape],
// which replaces "<", ">", "&", U+2028, and U+2029 are escaped
// to "\u003c", "\u003e", "\u0026", "\u2028", and "\u2029".
//
// Structs:
// Encode as JSON objects with only public fields of struct.
// Structs:
// Encode as JSON objects with only public fields of struct.
//
// Arrays:
// Encode as JSON array.
// Arrays:
// Encode as JSON array.
//
// Slices:
// Encode as JSON array.
// If slice is nil, encode as null JSON value.
// For the []byte type, encodes as a base64-encoded string.
// Slices:
// Encode as JSON array.
// If slice is nil, encode as null JSON value.
// For the []byte type, encodes as a base64-encoded string.
//
// Maps:
// Encode as JSON object.
// If map is nil, encode as null JSON value.
// The keys of the map always will be quoted.
// Also map's key type only can be: signed integer, unsigned integer and string.
// Other types will cause exceptional with [EncodeError.UnsupportedType].
// Maps:
// Encode as JSON object.
// If map is nil, encode as null JSON value.
// The keys of the map always will be quoted.
// Also map's key type only can be: signed integer, unsigned integer and string.
// Other types will cause exceptional with [EncodeError.UnsupportedType].
//
// Smart Pointers:
// If smart pointer is nil, encode as null JSON value.
// Otherwise, will encode dereferenced value.
// Smart Pointers:
// If smart pointer is nil, encode as null JSON value.
// Otherwise, will encode dereferenced value.
//
// Encode cannot represent cyclic data structures and does not handle them.
// Passing cyclic structures for encoding will result in an cycle at runtime.
Expand Down

0 comments on commit 6a11f73

Please sign in to comment.