Hi,
is it correct that the json_get_field returns the quotes from the json document?
Example:
{ "foo": "bar" }
json_get_field("$var(json)", "foo", "$var(result)");
result will contain "bar" with quotes ...
I was a little astonished to see that.
Flo
I changed the modules/json/json_funcs.c to work-around this issue. It is not complete, as it only handles string and int json types:
int json_get_field(struct sip_msg* msg, char* json, char* field, char* dst) { str json_s; str field_s; pv_spec_t *dst_pv; pv_value_t dst_val;
if (fixup_get_svalue(msg, (gparam_p)json, &json_s) != 0) { LM_ERR("cannot get json string value\n"); return -1; }
if (fixup_get_svalue(msg, (gparam_p)field, &field_s) != 0) { LM_ERR("cannot get field string value\n"); return -1; }
dst_pv = (pv_spec_t *)dst;
struct json_object *j = json_tokener_parse(json_s.s); enum json_type type = json_object_get_type(json_object_object_get(j, field_s.s));;
if (type == json_type_string) { char *value = (char*)json_object_get_string(json_object_object_get(j, field_s.s)); dst_val.rs.s = value; dst_val.rs.len = strlen(value); dst_val.flags = PV_VAL_STR; } else if (type == json_type_int) { int value = json_object_get_int(json_object_object_get(j, field_s.s)); dst_val.rs.s = '\0'; dst_val.rs.len = 0; dst_val.ri = value; dst_val.flags = PV_TYPE_INT|PV_VAL_INT; }
dst_pv->setf(msg, &dst_pv->pvp, (int)EQ_T, &dst_val);
return 1; }
Ron
-----Original Message----- From: sr-users-bounces@lists.sip-router.org [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Florian Lohoff Sent: September-13-13 10:00 AM To: sr-users@lists.sip-router.org Subject: [SR-Users] json module / quotes in result
Hi,
is it correct that the json_get_field returns the quotes from the json document?
Example:
{ "foo": "bar" }
json_get_field("$var(json)", "foo", "$var(result)");
result will contain "bar" with quotes ...
I was a little astonished to see that.
Flo
There's a significant overhaul to the json and jsonrpc-c modules available at https://github.com/flowroute/. I've been trying to find time to test and merge into maser.
On Fri, Sep 13, 2013 at 1:00 PM, Florian Lohoff f@zz.de wrote:
Hi,
is it correct that the json_get_field returns the quotes from the json document?
Example:
{ "foo": "bar" }
json_get_field("$var(json)", "foo", "$var(result)");
result will contain "bar" with quotes ...
I was a little astonished to see that.
Flo
Florian Lohoff f@zz.de
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux)
iQIVAwUBUjNEk5DdQSDLCfIvAQhinw//cmnkxyGKn3gzjeQVKUpUugK8LtNuckql o2MVtuSqnBGYGKUgHwB+GRTy6hZwMgE8YAhg7s171sYYRrbUg3bd90msajW/7Aaa dfZ80EBF33+mIzfzd7FHFgOgKZExfZhtyyuAP4fu1IulYpE6hgQzHAFI9st1VYBG PeIFneWNsed7p8lfY5QZW7eIdRWBVYAiJW+3kpHcmiUFnBLJmP4yhOepIn6eYWLc lmKjVBh0oK/aOPgqSeSviMGiQyEu/cvK9fPzHS2YdOYd6SfXcyKokOnIubvZwPeN DBJJ2Fsfg9JFS3USNg8InXJbyCnKbvEHwcYezKmkEPcP74eaek+HIFNGG8QNIaVk 0bKO1tgvXA2ZNe00Aehc7zHTGorS8EXgdDb2xiEP5jalsikWPFhwAOJPQfIz6JDR sxPLJbzGviV+1GQAr6e8OjVgPr+gpvlc+pgVbTy4K7hB4HchK/Zfggx2XQj67BOu nMWyQRx0yGJAIHj/PJ1ZgKhseXOyrVNXd4CyItDUrfvgj6lPBu8QMRhNjhwcJXaf Yzqof3WZWKhf5IgdvmDBFMSedlbR+x0eKD19LCPIt0z2u/DrvKC2ZuREFKT0XKGB +iwssqniS+KgUngZTwXzCULsUz3VSSKt7VzHrFF+1zAIVsCO3WknjvMEKzlxfV5c NLCpE3f1bH4= =Z42u -----END PGP SIGNATURE-----
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users