Documentation
¶
Index ¶
- func FromGo(v interface{}) object.Object
- func MustParseJSON(jsonStr string) object.Object
- func ParseJSON(jsonStr string) (object.Object, error)
- func ToBytes(obj object.Object) ([]byte, object.Object)
- func ToGo(obj object.Object) interface{}
- func ToGoError(obj object.Object) error
- func ToGoLimited(obj object.Object) (interface{}, *object.Error)
- func ToGoWithError(obj object.Object) (interface{}, *object.Error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromGo ¶
FromGo converts a Go interface{} value to a scriptling Object. It handles primitive types (nil, bool, int, float, string), nested structures (maps, slices), and falls back to JSON marshaling for unknown types.
func MustParseJSON ¶
MustParseJSON parses a JSON string and returns a Scriptling object, returning an Error object if parsing fails.
func ParseJSON ¶
ParseJSON parses a JSON string and returns a Scriptling object. It uses UseNumber() to preserve large integers, and builds dicts in the document's key order (as Python's json.loads does) rather than through a Go map, whose iteration order is random.
func ToBytes ¶ added in v0.19.0
ToBytes accepts a Bytes or String input and returns the raw byte slice. Used by libraries that historically took strings but now also accept Bytes (file I/O, HTTP bodies, socket send, etc.). Returns a Scriptling *Error object for any other type so callers can return it directly.
Bytes are returned as-is (no copy — treat the result as read-only). Strings are UTF-8 encoded into a fresh byte slice.
func ToGo ¶
ToGo converts a scriptling Object to a Go interface{}. It returns the underlying Go value for the object type.
func ToGoError ¶
ToGoError converts a scriptling Object to a Go error. If the object is an Error type, it returns a Go error with the error message. Otherwise, it returns nil.
func ToGoLimited ¶ added in v0.31.0
ToGoLimited is ToGo held to the limits of the interpreter on the calling goroutine. A value shared by several containers converts once per reference, so a small script value can expand into a huge Go value; the conversion counts what it builds and stops with a MemoryError once that passes the value limit or the memory left. Use it for script data handed to libraries (templates, encoders, request bodies).
Types ¶
This section is empty.