Exemple #1
0
Fichier : jq.go Projet : vantroy/jq
func toString(jv C.jv) string {
	// Dump it!
	dumped := C.jv_dump_string(jv, 0)
	defer C.jv_free(dumped)

	// Convert dump to string!
	strval := C.jv_string_value(dumped)
	return C.GoString(strval)
}
Exemple #2
0
// GetInvalidMessageAsString gets the error message for this Jv. If there is none it
// will return ("", false). Otherwise it will return the message as a string and true,
// converting non-string values if necessary. If you want the message in it's
// native Jv type use `GetInvalidMessage()`
//
// Consumes the invocant.
func (jv *Jv) GetInvalidMessageAsString() (string, bool) {
	msg := C.jv_invalid_get_msg(jv.jv)
	defer C.jv_free(msg)

	if C.jv_get_kind(msg) == C.JV_KIND_NULL {
		return "", false
	} else if C.jv_get_kind(msg) != C.JV_KIND_STRING {
		msg = C.jv_dump_string(msg, 0)
	}
	return C.GoString(C.jv_string_value(msg)), true
}
Exemple #3
0
func dumpJson(jv C.jv) string {
	strJv := C.jv_dump_string(jv, 0)
	result := C.jv_string_value(strJv)
	freeJv(strJv)
	return C.GoString(result)
}
Exemple #4
0
// Dump produces a human readable version of the string with the requested formatting.
//
// Consumes the invocant
func (jv *Jv) Dump(flags JvPrintFlags) string {
	jv_str := Jv{C.jv_dump_string(jv.jv, C.int(flags))}
	defer jv_str.Free()
	return jv_str._string()
}