0001 TPJSONTOUBF(3)
0002 ==============
0003 :doctype: manpage
0004
0005
0006 NAME
0007 ----
0008 tpjsontoubf - Convert JSON object to UBF buffer
0009
0010
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014
0015 int tpjsontoubf(UBFH *'p_ub', char *'buffer');
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 JSON formatted text in 'buffer' to UBF buffer. JSON should
0025 be formatted in single level. Where JSON field name matches UBF field name.
0026 If multiple occurrances/array of values is present in JSON,
0027 then it is converted as multiple field occurrences in UBF buffer.
0028
0029 For example following JSON buffer:
0030
0031 --------------------------------------------------------------------------------
0032 {
0033 "T_SHORT_FLD":1765,
0034 "T_LONG_FLD":[
0035 3333111,
0036 2
0037 ],
0038 "T_CHAR_FLD":"A",
0039 "T_FLOAT_FLD":1.330000,
0040 "T_DOUBLE_FLD":[
0041 1111.220000,
0042 333,
0043 444
0044 ],
0045 "T_STRING_FLD":"HELLO WORLD",
0046 "T_CARRAY_FLD":"AAECA0hFTExPIEJJTkFSWQQFAA=="
0047 }
0048 --------------------------------------------------------------------------------
0049
0050 Will be converted to following UBF buffer:
0051
0052 --------------------------------------------------------------------------------
0053 T_SHORT_FLD 1765
0054 T_LONG_FLD 3333111
0055 T_LONG_FLD 2
0056 T_CHAR_FLD A
0057 T_FLOAT_FLD 1.33000
0058 T_DOUBLE_FLD 1111.220000
0059 T_DOUBLE_FLD 333.000000
0060 T_DOUBLE_FLD 444.000000
0061 T_STRING_FLD HELLO WORLD
0062 T_CARRAY_FLD \00\01\02\03HELLO BINARY\04\05\00
0063 --------------------------------------------------------------------------------
0064
0065 Note that *BFLD_CARRAY* (binary data) fields should be present in base64 encoding
0066 in JSON buffer. It is up to user to allocate UBF buffer with enought size to fit
0067 the converted message.
0068
0069 RETURN VALUE
0070 ------------
0071 On success, *tpcall()* return zero; on error, -1 is returned, with *tperrno*
0072 set to indicate the error.
0073
0074 ERRORS
0075 ------
0076 Note that *tpstrerror()* returns generic error message plus custom message with
0077 debug info from last function call.
0078
0079 *TPEINVAL* Invalid JSON or invalid base64 encoding,
0080
0081 *TPESYSTEM* UBF sub-system error, JSON sub-system error.
0082
0083 *TPEOS* System failure occurred during serving. See logs i.e. user log, or
0084 debugs for more info. In case of insufficient memory this error will be
0085 generated too.
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)*, *tpubftojson(3)* *tpjsontoview(3)* *tpviewtojson(3)*
0098
0099 COPYING
0100 -------
0101 (C) Mavimax, Ltd
0102