User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v7.0.x:api:xatmi:tpjsontoubf.3

TPJSONTOUBF

TPJSONTOUBF

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
EXAMPLE
BUGS
SEE ALSO
COPYING

NAME

tpjsontoubf − Convert JSON object to UBF buffer

SYNOPSIS

#include <atmi.h>

int tpjsontoubf(UBFH *p_ub, char *buffer);

For XATMI client link with −latmiclt −latmi −lubf −lnstd −lpthread −lrt −lm

For XATMI server link with −latmisrv|−latmisrvnomain|−latmisrvinteg −latmi −lubf −lnstd −lpthread −lrt −lm

DESCRIPTION

Function converts JSON formatted text in buffer to UBF buffer. JSON should be formatted in single level. Where JSON field name matches UBF field name. If multiple occurrances/array of values is present in JSON, then it is converted as multiple field occurrences in UBF buffer.

For example following JSON buffer:

{
"T_SHORT_FLD":1765,
"T_LONG_FLD":[
3333111,
2
],
"T_CHAR_FLD":"A",
"T_FLOAT_FLD":1.330000,
"T_DOUBLE_FLD":[
1111.220000,
333,
444
],
"T_STRING_FLD":"HELLO WORLD",
"T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
}

Will be converted to following UBF buffer:

T_SHORT_FLD 1765
T_LONG_FLD 3333111
T_LONG_FLD 2
T_CHAR_FLD A
T_FLOAT_FLD 1.33000
T_DOUBLE_FLD 1111.220000
T_DOUBLE_FLD 333.000000
T_DOUBLE_FLD 444.000000
T_STRING_FLD HELLO WORLD
T_CARRAY_FLD \00\01\02\03HELLO BINARY\04\05\00

Note that BFLD_CARRAY (binary data) fields should be present in base64 encoding in JSON buffer. It is up to user to allocate UBF buffer with enought size to fit the converted message.

RETURN VALUE

On success, tpcall() return zero; on error, −1 is returned, with tperrno set to indicate the error.

ERRORS

Note that tpstrerror() returns generic error message plus custom message with debug info from last function call.

TPEINVAL Invalid JSON or invalid base64 encoding,

TPESYSTEM UBF sub−system error, JSON sub−system error.

TPEOS System failure occurred during serving. See logs i.e. user log, or debugs for more info. In case of insufficient memory this error will be generated too.

EXAMPLE

See atmitest/test024_json/atmiclt24.c for sample code.

BUGS

Report bugs to support@mavimax.com

SEE ALSO

ndrxdebug.conf(5), tpubftojson(3) tpjsontoview(3) tpviewtojson(3)*

COPYING

© Mavimax, Ltd