From: Victor Seva <vseva@sipwise.com>
Date: Fri, 11 Dec 2020 16:56:18 +0100
Subject: cfgt: skip $_s and $avp with id 0

---
 src/modules/cfgt/cfgt_json.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/modules/cfgt/cfgt_json.c b/src/modules/cfgt/cfgt_json.c
index 8089c02..04aa032 100644
--- a/src/modules/cfgt/cfgt_json.c
+++ b/src/modules/cfgt/cfgt_json.c
@@ -43,6 +43,10 @@ int _cfgt_get_array_avp_vals(struct sip_msg *msg, pv_param_t *param,
 		LM_ERR("invalid name\n");
 		return -1;
 	}
+	if(name_type == 0 && avp_name.n == 0) {
+		LM_DBG("skip name_type:%d avp_name:%d\n", name_type, avp_name.n);
+		return 0;
+	}
 	*jobj = srjson_CreateArray(jdoc);
 	if(*jobj == NULL) {
 		LM_ERR("cannot create json object\n");
@@ -286,8 +290,8 @@ int cfgt_get_json(struct sip_msg *msg, unsigned int mask, srjson_doc_t *jdoc,
 						el = el->next;
 						continue;
 					}
-					if(srjson_GetArraySize(jdoc, jobj) == 0
-							&& !(mask & CFGT_DP_NULL)) {
+					if(jobj == NULL || (srjson_GetArraySize(jdoc, jobj) == 0
+							&& !(mask & CFGT_DP_NULL))) {
 						el = el->next;
 						continue;
 					}
@@ -319,6 +323,11 @@ int cfgt_get_json(struct sip_msg *msg, unsigned int mask, srjson_doc_t *jdoc,
 					el = el->next;
 					continue;
 				}
+				if(el->pvname.len > 3 && strncmp("$_s", el->pvname.s, 3) == 0) {
+					LM_DBG("skip dynamic format [%.*s]\n", el->pvname.len, el->pvname.s);
+					el = el->next;
+					continue;
+				}
 				if(pv_get_spec_value(msg, &el->spec, &value) != 0) {
 					LM_WARN("can't get value[%.*s]\n", el->pvname.len,
 							el->pvname.s);
