serializedcall

package module
v0.0.0-...-12c1508 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: Apache-2.0 Imports: 8 Imported by: 1

README

go-json-call

Library that allows arbitrary Go functions to be called with JSON-formatted arguments and return values. For example:

let args be {"0": 6, "1": 3}

func div(x,y int) int {
    return x / y
}

results := CallWithJSON(div, args)

results is then {"0": 2}

The JSON is indexed by the number of the argument and result.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallWithJSON

func CallWithJSON(f interface{}, jsonBytes []byte) ([]byte, error)

CallWithJSON Calls a function f with arguments from a JSON byte stream

func CallWithXML

func CallWithXML(f interface{}, xmlBytes []byte) ([]byte, error)

CallWithXML Calls a function f with arguments from a XML byte stream

func MarshalArgs

func MarshalArgs(args ...interface{}) ([]byte, error)

MarshalArgs converts its arguments in order into the json argument format compatible with go-json-call. Float values that are precise ints are converted to integers, unfortunately.

func MarshalXMLArgs

func MarshalXMLArgs(args ...interface{}) ([]byte, error)

MarshalXMLArgs converts a list of arguments into XML

func UnmarshalArgs

func UnmarshalArgs(jsonBytes []byte) ([]interface{}, error)

UnmarshalArgs converts a json argument format into a slice of How to handle ambiguous json encodings (1.0 (go) -> 1 (json) -> 1 or 1.0 (go))

func UnmarshalXMLArgs

func UnmarshalXMLArgs(xmlBytes []byte) ([]interface{}, error)

UnmarshalXMLArgs converts XML into a slice of go data

Types

type Message

type Message struct {
	Error   string
	Message string
	Payload string
}

Jump to

Keyboard shortcuts

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