NoteIf there are some special characters such as ‘\b’, ‘\f’, ‘\n’, ‘\r’, ‘\t’, ‘\’, and ‘"’ on key or value, for example, PMLOGKS("KEY", g_strescape("my \"quoted\" string value"))
, you must escape that string. If you do not follow this rule, the following error message, for example, is written to the log file.
2013-08-10T23:48:23.365813Z [814] user.err WebAppMgr PmLogLib INVALID_JSON {"CONTEXT":"LunaSysMgrJS","MSGID":"JSLOG"}
You can use GLib’s g_strescape()
function for escaping string. However, you must pay attention to use g_strescape()
, because this function returns a newly allocated memory for the escaped string.
For more details about g_strescape()
, refer to GLib Reference Manual.