Browse code

modules: readme files regenerated - jansson ... [skip ci]

Kamailio Dev authored on 22/03/2021 15:31:17
Showing 1 changed files
... ...
@@ -138,7 +138,7 @@ xlog("L_INFO", "foo is $var(n)");
138 138
    'false', or 'null'.
139 139
 
140 140
    Note: If you want to insert a JSON-Integer value exceeding the
141
-   C-Integer boundaries (e.g. C-type long), the a the number can be
141
+   C-Integer boundaries (e.g. C-type long), then the number can be
142 142
    provided as a string.
143 143
 
144 144
    Example 1.2. jansson_set usage
Browse code

modules: readme files regenerated - jansson ... [skip ci]

Kamailio Dev authored on 23/10/2020 08:46:37
Showing 1 changed files
... ...
@@ -33,7 +33,9 @@ Carsten Bock
33 33
               3.2. jansson_set(type, key/path, value, result)
34 34
               3.3. jansson_append(type, key/path, value, result)
35 35
               3.4. jansson_array_size(key/path, src, dst)
36
-              3.5. jansson_get_field(src, field_name, dst)
36
+              3.5. jansson_xdecode(json, xavp)
37
+              3.6. jansson_xencode(xavp, pv)
38
+              3.7. jansson_get_field(src, field_name, dst)
37 39
 
38 40
    List of Examples
39 41
 
... ...
@@ -42,7 +44,9 @@ Carsten Bock
42 44
    1.3. jansson_append usage
43 45
    1.4. jansson_array_size usage
44 46
    1.5. array concatenation
45
-   1.6. jansson_get_field usage
47
+   1.6. jansson_xdecode usage
48
+   1.7. jansson_xencode usage
49
+   1.8. jansson_get_field usage
46 50
 
47 51
 Chapter 1. Admin Guide
48 52
 
... ...
@@ -60,7 +64,9 @@ Chapter 1. Admin Guide
60 64
         3.2. jansson_set(type, key/path, value, result)
61 65
         3.3. jansson_append(type, key/path, value, result)
62 66
         3.4. jansson_array_size(key/path, src, dst)
63
-        3.5. jansson_get_field(src, field_name, dst)
67
+        3.5. jansson_xdecode(json, xavp)
68
+        3.6. jansson_xencode(xavp, pv)
69
+        3.7. jansson_get_field(src, field_name, dst)
64 70
 
65 71
 1. Overview
66 72
 
... ...
@@ -89,7 +95,9 @@ Chapter 1. Admin Guide
89 95
    3.2. jansson_set(type, key/path, value, result)
90 96
    3.3. jansson_append(type, key/path, value, result)
91 97
    3.4. jansson_array_size(key/path, src, dst)
92
-   3.5. jansson_get_field(src, field_name, dst)
98
+   3.5. jansson_xdecode(json, xavp)
99
+   3.6. jansson_xencode(xavp, pv)
100
+   3.7. jansson_get_field(src, field_name, dst)
93 101
 
94 102
 3.1.  jansson_get(key/path, src, dst)
95 103
 
... ...
@@ -223,7 +231,31 @@ while($var(count) < $var(appendme_size)) {
223 231
 }
224 232
 ...
225 233
 
226
-3.5.  jansson_get_field(src, field_name, dst)
234
+3.5.  jansson_xdecode(json, xavp)
235
+
236
+   Parse a JSON string in 'json' and store the elements in xapv 'xavp'.
237
+   Top-level JSON must be an object or an array of objects. Nested arrays
238
+   and objects are not decoded but stored as string.
239
+
240
+   Example 1.6. jansson_xdecode usage
241
+...
242
+jansson_xdecode('{"foo":"bar"}', "js");
243
+xlog("foo is $xavp(js=>foo)");
244
+...
245
+
246
+3.6.  jansson_xencode(xavp, pv)
247
+
248
+   Encode the items in the xavp 'xavp' as JSON and store the result in a
249
+   pv. Nested xavps's are not supported.
250
+
251
+   Example 1.7. jansson_xencode usage
252
+...
253
+$xavp(a=>foo) = "bar";
254
+jansson_xencode("a", "$var(js)");
255
+# $var(js) = '{"foo":"bar"}'
256
+...
257
+
258
+3.7.  jansson_get_field(src, field_name, dst)
227 259
 
228 260
    Copy field 'field_name' from json object 'src' and store it in pvar
229 261
    'dst'.
... ...
@@ -232,7 +264,7 @@ while($var(count) < $var(appendme_size)) {
232 264
    now it is just a wrapper around jansson_get, and its functionality is
233 265
    the same.
234 266
 
235
-   Example 1.6. jansson_get_field usage
267
+   Example 1.8. jansson_get_field usage
236 268
 ...
237 269
 jansson_get_field("{'foo':'bar'}", "foo", "$var(foo)");
238 270
 xlog("foo is $var(foo)");
Browse code

modules: readme files regenerated - app_lua_sr ... [skip ci]

Kamailio Dev authored on 25/05/2020 09:21:05
Showing 1 changed files
... ...
@@ -10,8 +10,6 @@ Matthew Williams
10 10
 
11 11
    <matthew@flowroute.com>
12 12
 
13
-Edited by
14
-
15 13
 Carsten Bock
16 14
 
17 15
    <carsten@ng-voice.com>
Browse code

modules: readme files regenerated - acc ... [skip ci]

Kamailio Dev authored on 28/02/2018 17:03:37 • The Root committed on 28/02/2018 19:11:36
Showing 1 changed files
... ...
@@ -43,7 +43,7 @@ Carsten Bock
43 43
    1.2. jansson_set usage
44 44
    1.3. jansson_append usage
45 45
    1.4. jansson_array_size usage
46
-   1.5. array concatination
46
+   1.5. array concatenation
47 47
    1.6. jansson_get_field usage
48 48
 
49 49
 Chapter 1. Admin Guide
... ...
@@ -127,7 +127,7 @@ xlog("L_INFO", "foo is $var(n)");
127 127
    The path string works the same as in jansson_get.
128 128
 
129 129
    Valid 'type' parameters are 'integer', 'real', 'string', 'object',
130
-   'array', 'true', 'false', and 'null' as well as abbriviated names such
130
+   'array', 'true', 'false', and 'null' as well as abbreviated names such
131 131
    as 'int', 'str', and 'obj'. 'value' is ignored when type is 'true',
132 132
    'false', or 'null'.
133 133
 
... ...
@@ -212,7 +212,7 @@ while($var(count) < $var(size)) {
212 212
 }
213 213
 ...
214 214
 
215
-   Example 1.5. array concatination
215
+   Example 1.5. array concatenation
216 216
 ...
217 217
 $var(count) = 0;
218 218
 $var(appendme) = '[0,1]';
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,241 @@
1
+JANSSON Module
2
+
3
+Joe Hillenbrand
4
+
5
+   <joe@flowroute.com>
6
+
7
+Edited by
8
+
9
+Matthew Williams
10
+
11
+   <matthew@flowroute.com>
12
+
13
+Edited by
14
+
15
+Carsten Bock
16
+
17
+   <carsten@ng-voice.com>
18
+
19
+   Copyright © 2013 Flowroute LLC (flowroute.com)
20
+     __________________________________________________________________
21
+
22
+   Table of Contents
23
+
24
+   1. Admin Guide
25
+
26
+        1. Overview
27
+        2. Dependencies
28
+
29
+              2.1. Kamailio Modules
30
+              2.2. External Libraries or Applications
31
+
32
+        3. Functions
33
+
34
+              3.1. jansson_get(key/path, src, dst)
35
+              3.2. jansson_set(type, key/path, value, result)
36
+              3.3. jansson_append(type, key/path, value, result)
37
+              3.4. jansson_array_size(key/path, src, dst)
38
+              3.5. jansson_get_field(src, field_name, dst)
39
+
40
+   List of Examples
41
+
42
+   1.1. jansson_get usage
43
+   1.2. jansson_set usage
44
+   1.3. jansson_append usage
45
+   1.4. jansson_array_size usage
46
+   1.5. array concatination
47
+   1.6. jansson_get_field usage
48
+
49
+Chapter 1. Admin Guide
50
+
51
+   Table of Contents
52
+
53
+   1. Overview
54
+   2. Dependencies
55
+
56
+        2.1. Kamailio Modules
57
+        2.2. External Libraries or Applications
58
+
59
+   3. Functions
60
+
61
+        3.1. jansson_get(key/path, src, dst)
62
+        3.2. jansson_set(type, key/path, value, result)
63
+        3.3. jansson_append(type, key/path, value, result)
64
+        3.4. jansson_array_size(key/path, src, dst)
65
+        3.5. jansson_get_field(src, field_name, dst)
66
+
67
+1. Overview
68
+
69
+   This module provides operations on JSON strings using JANSSON library.
70
+   It has support for JSON-PATH operations.
71
+
72
+2. Dependencies
73
+
74
+   2.1. Kamailio Modules
75
+   2.2. External Libraries or Applications
76
+
77
+2.1. Kamailio Modules
78
+
79
+   The following modules must be loaded before this module:
80
+     * None
81
+
82
+2.2. External Libraries or Applications
83
+
84
+   The following libraries or applications must be installed before
85
+   running Kamailio with this module loaded:
86
+     * jansson (http://www.digip.org/jansson/), tested with: 2.2+
87
+
88
+3. Functions
89
+
90
+   3.1. jansson_get(key/path, src, dst)
91
+   3.2. jansson_set(type, key/path, value, result)
92
+   3.3. jansson_append(type, key/path, value, result)
93
+   3.4. jansson_array_size(key/path, src, dst)
94
+   3.5. jansson_get_field(src, field_name, dst)
95
+
96
+3.1.  jansson_get(key/path, src, dst)
97
+
98
+   Copy the value at the location 'path' from the json object 'src' and
99
+   store it in pvar 'dst'.
100
+
101
+   The path string supports dot delimited notation (e.g. foo.bar.baz),
102
+   array notation (e.g. [0]), or a combination of the two (e.g.
103
+   foo.bar[0][1].baz).
104
+
105
+   Returns FALSE if the data can not be parsed, TRUE otherwise.
106
+
107
+   The function can put a string, integer, null, or new json string into
108
+   destination. If the key/path can't be found in the JSON data structure,
109
+   the pvar is not changed. If it had a previous value, that value remains
110
+   unchanged.
111
+
112
+   Note: For JSON-Integer values exceeding the C-Integer boundaries, a
113
+   String representing the number is returned.
114
+
115
+   Example 1.1. jansson_get usage
116
+...
117
+if(!jansson_get("inner.deep.list[3]", $var(myjson), "$var(n)")) {
118
+        xlog("L_ERR", "Can't parse json data");
119
+}
120
+xlog("L_INFO", "foo is $var(n)");
121
+...
122
+
123
+3.2.  jansson_set(type, key/path, value, result)
124
+
125
+   Insert 'value' as 'type' at location 'path' into 'result'.
126
+
127
+   The path string works the same as in jansson_get.
128
+
129
+   Valid 'type' parameters are 'integer', 'real', 'string', 'object',
130
+   'array', 'true', 'false', and 'null' as well as abbriviated names such
131
+   as 'int', 'str', and 'obj'. 'value' is ignored when type is 'true',
132
+   'false', or 'null'.
133
+
134
+   Note: If you want to insert a JSON-Integer value exceeding the
135
+   C-Integer boundaries (e.g. C-type long), the a the number can be
136
+   provided as a string.
137
+
138
+   Example 1.2. jansson_set usage
139
+...
140
+# create a new json object and put a string in it at key "mystr"
141
+jansson_set("string", "mystr", "my input string", "$var(myjson)");
142
+# $var(myjson) =='{"mystr":"my input string"}'
143
+
144
+# add other values
145
+jansson_set("integer", "count", 9000, "$var(myjson)");
146
+jansson_set("true", "mybool", 0, "$var(myjson)");
147
+jansson_set("real", "pi", "3.14159", "$var(myjson)");
148
+# $var(myjson) == '{"mystr":"my input string", "count":9000, "mybool":true, "pi"
149
+:3.14159}'
150
+
151
+# add a nested object
152
+jansson_set("obj", "myobj", '{"foo":"bar"}', "$var(myjson)");
153
+# $var(myjson) =='{"mystr":"my input string", "count":9000, "mybool":true, "pi":
154
+3.14159, "myobj":{"foo":"bar"}}'
155
+
156
+# change the nested object
157
+jansson_set("str", "myobj.foo", "baz", "$var(myjson)");
158
+# $var(myjson) == '{"mystr":"my input string", "count":9000, "mybool":true, "pi"
159
+:3.14159, "myobj":{"foo":"baz"}}'
160
+...
161
+
162
+3.3.  jansson_append(type, key/path, value, result)
163
+
164
+   Like jansson_set but can be used to append to arrays. It can also be
165
+   used to combine two json objects.
166
+
167
+   Note that when appending a json object to another json object, if there
168
+   is a key that is shared between the two objects, that value will be
169
+   overwritten by the new object.
170
+
171
+   Example 1.3. jansson_append usage
172
+...
173
+# create a new json array and append values to it
174
+$var(myarray) = '[]';
175
+jansson_append("int", "", 0, "$var(myarray)");
176
+jansson_append("int", "", 1, "$var(myarray)");
177
+jansson_append("int", "", 2, "$var(myarray)");
178
+jansson_append("int", "", 3, "$var(myarray)");
179
+jansson_append("int", "", 4, "$var(myarray)");
180
+# $var(myarray) == '[0,1,2,3,4]'
181
+
182
+# add that array to an object
183
+jansson_set("array", "list", $var(myarray), "$var(myjson)");
184
+# $var(myjson) == '{"list":[0,1,2,3,4]}'
185
+
186
+# append another value to the list
187
+jansson_append("int", "list", 5, "$var(myjson)");
188
+# $var(myjson) == '{"list":[0,1,2,3,4,5]}'
189
+
190
+# combining two json objects
191
+$var(newobj) = '{"b":2, "c":3}';
192
+jansson_append('obj', "", '{"a":1, "b":100}', "$var(newobj)");
193
+# $var(newobj) == '{"a":1,"b":100","c":3}';
194
+...
195
+
196
+3.4.  jansson_array_size(key/path, src, dst)
197
+
198
+   Puts the size of the array in 'src' at location 'path' into the pvar
199
+   'dst'.
200
+
201
+   This is particularly useful for looping through an array. See example.
202
+
203
+   Example 1.4. jansson_array_size usage
204
+...
205
+$var(array) = "{\"loopme\":[0,1,2,3,4,5]}";
206
+$var(count) = 0;
207
+jansson_array_size("loopme", $var(array), "$var(size)");
208
+while($var(count) < $var(size)) {
209
+    jansson_get("loopme[$var(count)]", $var(array), "$var(v)");
210
+    xlog("loopme[$var(count)] == $var(v)\n");
211
+    $var(count) = $var(count) + 1;
212
+}
213
+...
214
+
215
+   Example 1.5. array concatination
216
+...
217
+$var(count) = 0;
218
+$var(appendme) = '[0,1]';
219
+$var(mylist) = '[2,3,4,5]';
220
+jansson_array_size("", $var(mylist), "$var(appendme_size)");
221
+while($var(count) < $var(appendme_size)) {
222
+    jansson_get("[$var(count)]", $var(mylist), "$var(tmp)");
223
+    jansson_append('int', "", $var(tmp), "$var(appendme)");
224
+    $var(count) = $var(count) + 1;
225
+}
226
+...
227
+
228
+3.5.  jansson_get_field(src, field_name, dst)
229
+
230
+   Copy field 'field_name' from json object 'src' and store it in pvar
231
+   'dst'.
232
+
233
+   This function is deprecated but kept for backwards compatibility. Right
234
+   now it is just a wrapper around jansson_get, and its functionality is
235
+   the same.
236
+
237
+   Example 1.6. jansson_get_field usage
238
+...
239
+jansson_get_field("{'foo':'bar'}", "foo", "$var(foo)");
240
+xlog("foo is $var(foo)");
241
+...