Back to home page

Enduro/X

 
 

    


0001 TPJSONTOVIEW(3)
0002 ===============
0003 :doctype: manpage
0004 
0005 
0006 NAME
0007 ----
0008 tpjsontoview - Convert JSON object to VIEW buffer
0009 
0010 
0011 SYNOPSIS
0012 --------
0013 #include <atmi.h>
0014 
0015 char * tpjsontoview(char *'view', char *'buffer')
0016 
0017 For XATMI client link with '-latmiclt -latmi -lview -lnstd -lpthread -lrt -lm'
0018 
0019 For XATMI server link with '-latmisrv|-latmisrvnomain|-latmisrvinteg -latmi -lview -lnstd -lpthread -lrt -lm'
0020 
0021 DESCRIPTION
0022 -----------
0023 Function converts JSON formatted text in 'buffer' to VIEW buffer. JSON should
0024 be formatted in two levels. In first level there is single field named as VIEW
0025 name, and in second level JSON field names matches VIEW field name.
0026 If multiple occurrences/array of values is present in JSON, 
0027 then it is converted in VIEW field array elements. The function in case of success
0028 returns XATMI (tpcalloc'ed) VIEW buffer, which is initialised to NULL values and
0029 then recovered from JSON. Loaded view name is loaded into 'view' parameter, which
0030 must not be NULL, required size of the field is 34 bytes.
0031 
0032 For example following JSON:
0033 
0034 --------------------------------------------------------------------------------
0035 {  
0036         "MYVIEW2":
0037         {
0038                 
0039                 "tshort1":100,
0040                 "tlong1":5,
0041                 "tchar1":"",
0042                 "tfloat1":1.10000,
0043                 "tdouble1":0.000000,
0044                 "tstring1":["HELLO WORLD", "Enduro/X", "HELLO WORLD],
0045                 "tcarray1":"SGVsbG8gd29ybGQ="
0046         }
0047 }
0048 --------------------------------------------------------------------------------
0049 
0050 Can be loaded into following VIEW:
0051 
0052 --------------------------------------------------------------------------------
0053 VIEW MYVIEW2
0054 #type    cname      fbname              count   flag    size    null
0055 short    tshort1    -                   1       -       -       -
0056 long     tlong1     -                   1       -       -       -
0057 char     tchar1     -                   1       -       -       -
0058 float    tfloat1    -                   1       -       -       -
0059 double   tdouble1   -                   1       -       -       -
0060 string   tstring1   -                   3       -       15      -
0061 carray   tcarray1   -                   1       -       10      -
0062 END
0063 --------------------------------------------------------------------------------
0064 
0065 Note that *carray* (binary data) fields should be present in base64 encoding
0066 in JSON buffer.
0067 
0068 RETURN VALUE
0069 ------------
0070 On success, *tpcall()* return pointer to XATMI allocated VIEW buffer; on error, 
0071 NULL is returned, with *tperrno* set to indicate the error.
0072 
0073 ERRORS
0074 ------
0075 Note that *tpstrerror()* returns generic error message plus custom message with 
0076 debug info from last function call.
0077 
0078 *TPEINVAL* Invalid JSON or invalid base64 encoding, 'view' is NULL or 'buffer'
0079 is NULL.
0080 
0081 *TPEOTYPE* Invalid type specified to function - 'view' name specified in JSON message
0082 is not found in view files.
0083 
0084 *TPESYSTEM* VIEW sub-system error, JSON sub-system error or Enduro/X environment
0085 not configured.
0086 
0087 *TPEOS* System failure occurred during serving. See logs i.e. user log, or 
0088 debugs for more info. In case of insufficient memory this error will be 
0089 generated too.
0090 
0091 
0092 EXAMPLE
0093 -------
0094 See *atmitest/test040_typedview/atmiclt40.c* for sample code.
0095 
0096 BUGS
0097 ----
0098 Report bugs to support@mavimax.com 
0099 
0100 SEE ALSO
0101 --------
0102 *tpviewtojson(3)* *viewfile(5)* *viewc(8)* *ex_env(5)*
0103 
0104 COPYING
0105 -------
0106 (C) Mavimax, Ltd
0107 
0108