aotrautils-srv 0.0.598 → 0.0.600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (24/09/2023-23:
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:55)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -4983,7 +4983,66 @@ JSON.recycle=function recycle($){
|
|
|
4983
4983
|
|
|
4984
4984
|
|
|
4985
4985
|
|
|
4986
|
+
// JSON parsing management :
|
|
4987
|
+
function parseJSON(strParam){
|
|
4988
|
+
|
|
4989
|
+
if(!isString(strParam)) return strParam;
|
|
4990
|
+
|
|
4991
|
+
if (nothing(strParam))
|
|
4992
|
+
return null;
|
|
4993
|
+
var str=toOneSimplifiedLine(strParam.trim())
|
|
4994
|
+
// OLD : Safer, but necessited to never use «'» in literal strings, and use «´» acute character instead !
|
|
4995
|
+
.replace(/'/gim, "\"");
|
|
4996
|
+
// DOES NOT WORK :
|
|
4997
|
+
// .replace(/,'/gim, ",\"")
|
|
4998
|
+
// .replace(/:'/gim, ":\"")
|
|
4999
|
+
// .replace(/{'/gim, "{\"")
|
|
5000
|
+
// .replace(/}'/gim, "}\"")
|
|
5001
|
+
// .replace(/\['/gim, "[\"")
|
|
5002
|
+
// .replace(/\]'/gim, "]\"");
|
|
5003
|
+
try {
|
|
5004
|
+
|
|
5005
|
+
if((JSON && JSON.parse && typeof JSON.parse !== "undefined" && typeof JSON.parse === "function"
|
|
5006
|
+
) || jQuery)
|
|
5007
|
+
return JSON.parse(str);
|
|
5008
|
+
if(typeof jQuery !== "undefined" && typeof jQuery.parseJSON !== "undefined" && typeof jQuery.parseJSON === "function"){
|
|
5009
|
+
return jQuery.parseJSON(str);
|
|
5010
|
+
}
|
|
5011
|
+
throw new Error("ERROR : No JSON subsystem found to parse the JSON string.");
|
|
5012
|
+
|
|
5013
|
+
} catch (error){
|
|
5014
|
+
// TRACE
|
|
5015
|
+
log("WARN : Error parsing string «" + strParam + "» as JSON. Trying last-chance fallback.");
|
|
5016
|
+
try {
|
|
5017
|
+
var obj=eval("(" + str + ")");
|
|
5018
|
+
|
|
5019
|
+
return obj;
|
|
5020
|
+
} catch (error2){
|
|
5021
|
+
|
|
5022
|
+
// TRACE
|
|
5023
|
+
log(error2);
|
|
5024
|
+
log("ERROR : Error parsing string «" + strParam + "» as JSON. Last-chance fallback failed." +
|
|
5025
|
+
" CHECK IF THERE IS ANY «'» SINGLE QUOTE CHARACTER IN YOUR LITERALS STRINGS, AND REPLACE IT WITH «´» ACUTE CHARACTER INSTEAD.");
|
|
5026
|
+
|
|
5027
|
+
}
|
|
4986
5028
|
|
|
5029
|
+
}
|
|
5030
|
+
return null;
|
|
5031
|
+
}
|
|
5032
|
+
|
|
5033
|
+
function stringifyObject(objectToStringify){
|
|
5034
|
+
|
|
5035
|
+
if(nothing(objectToStringify)) return null;
|
|
5036
|
+
|
|
5037
|
+
if (JSON && JSON.stringify && typeof JSON.stringify !== "undefined" && typeof JSON.stringify === "function"){
|
|
5038
|
+
return JSON.stringify(objectToStringify);
|
|
5039
|
+
}
|
|
5040
|
+
if(typeof jQuery !== "undefined" && typeof jQuery.stringify !== "undefined" && typeof jQuery.stringify === "function"){
|
|
5041
|
+
return jQuery.stringify(objectToStringify);
|
|
5042
|
+
}
|
|
5043
|
+
log("ERROR : No JSON subsystem found to stringify the javascript object.");
|
|
5044
|
+
return null;
|
|
5045
|
+
}
|
|
4987
5046
|
|
|
4988
5047
|
|
|
4989
5048
|
|
|
@@ -4995,7 +5054,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
4995
5054
|
|
|
4996
5055
|
|
|
4997
5056
|
|
|
4998
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (24/09/2023-23:
|
|
5057
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:55)»*/
|
|
4999
5058
|
/*-----------------------------------------------------------------------------*/
|
|
5000
5059
|
|
|
5001
5060
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.600",
|
|
4
4
|
"main": "aotrautils-srv.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|