0001 TPUBFTOJSON(3)
0002 ==============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tpubftojson - Convert UBF buffer to JSON object
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015 int tpubftojson(UBFH *'p_ub', char *'buffer', int 'bufsize');
0016
0017
0018 For XATMI client link with '-latmiclt -latmi -lubf -lnstd -lpthread -lrt -lm'
0019
0020 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lubf -lnstd -lpthread -lrt -lm'
0021
0022 DESCRIPTION
0023 -----------
0024 Function converts UBF buffer in 'p_ub' to JSON object string to 'buffer' string.
0025 The field 'bufsize' must indicate the space in *buffer*. If the size is not enough,
0026 function will fail.
0027
0028 For example, following buffer in 'p_ub':
0029
0030 --------------------------------------------------------------------------------
0031 T_SHORT_FLD 1765
0032 T_LONG_FLD 3333111
0033 T_LONG_FLD 2
0034 T_CHAR_FLD A
0035 T_FLOAT_FLD 1.33000
0036 T_DOUBLE_FLD 1111.220000
0037 T_DOUBLE_FLD 333.000000
0038 T_DOUBLE_FLD 444.000000
0039 T_STRING_FLD HELLO WORLD
0040 T_CARRAY_FLD \00\01\02\03HELLO BINARY\04\05\00
0041 --------------------------------------------------------------------------------
0042
0043
0044 will be converted in following JSON buffer:
0045
0046 --------------------------------------------------------------------------------
0047 {
0048 "T_SHORT_FLD":1765,
0049 "T_LONG_FLD":[
0050 3333111,
0051 2
0052 ],
0053 "T_CHAR_FLD":"A",
0054 "T_FLOAT_FLD":1.330000,
0055 "T_DOUBLE_FLD":[
0056 1111.220000,
0057 333,
0058 444
0059 ],
0060 "T_STRING_FLD":"HELLO WORLD",
0061 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0062 }
0063 --------------------------------------------------------------------------------
0064
0065 CARRAY (byte array) data will be converted as base64 string in JSON. In output
0066 JSON output formatting newlines might not be present.
0067
0068 Any *BFLD_STRING* fields converted must be valid *UTF-8* encoded strings.
0069
0070 RETURN VALUE
0071 ------------
0072 On success, *tpacall()* return call descriptor (>0); on error, -1 is returned,
0073 with *tperrno* set to indicate the error.
0074
0075 ERRORS
0076 ------
0077 Note that *tpstrerror()* returns generic error message plus custom message with
0078 debug info from last function call.
0079
0080 *TPESYSTEM* System failure occurred during serving.
0081 See logs i.e. user log, or debugs for more info. Might be insufficient memory,
0082 JSON or UBF library failure. String does not correspond to *UTF-8* format.
0083
0084 *TPEOS* Not enough space in output 'buffer'.
0085
0086
0087 EXAMPLE
0088 -------
0089 See *atmitest/test024_json/atmiclt24.c* for sample code.
0090
0091 BUGS
0092 ----
0093 Report bugs to support@mavimax.com
0094
0095 SEE ALSO
0096 --------
0097 *ndrxdebug.conf(5)*, *tpjsontoubf(3)*
0098
0099 COPYING
0100 -------
0101 (C) Mavimax, Ltd
0102