|
@@ -14,7 +14,37 @@
|
|
|
* limitations under the License.
|
|
|
*
|
|
|
*/
|
|
|
-directive_module.directive('showtextmodal', showTextModalDirective);
|
|
|
+directive_module.directive('showtextmodal', showTextModalDirective)
|
|
|
+ .filter('jsonBigIntFilter', function () {
|
|
|
+ return function (text) {
|
|
|
+ if (typeof(text) === "undefined" || typeof JSON.parse(text) !== "object"
|
|
|
+ || !text) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const numberRegex = /\d{16,}/g;
|
|
|
+ const splitRegex = /"\d\d+"/;
|
|
|
+ const splitArray = text.split(splitRegex);
|
|
|
+ const matchResult = text.match(numberRegex);
|
|
|
+
|
|
|
+ if (!matchResult) {
|
|
|
+ return text;
|
|
|
+ }
|
|
|
+
|
|
|
+ let resultStr = '';
|
|
|
+ let index = 0;
|
|
|
+
|
|
|
+ Object.keys(splitArray).forEach(function (key) {
|
|
|
+ resultStr = resultStr.concat(splitArray[key]);
|
|
|
+ if (typeof(matchResult[index]) !== "undefined") {
|
|
|
+ resultStr = resultStr.concat(matchResult[index++])
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return resultStr;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
function showTextModalDirective(AppUtil) {
|
|
|
return {
|
|
@@ -31,7 +61,7 @@ function showTextModalDirective(AppUtil) {
|
|
|
function init() {
|
|
|
scope.jsonObject = undefined;
|
|
|
if (isJsonText(scope.text)) {
|
|
|
- scope.jsonObject = JSON.parse(scope.text);
|
|
|
+ scope.jsonObject = parseBigInt(scope.text);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -42,6 +72,28 @@ function showTextModalDirective(AppUtil) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function parseBigInt(str) {
|
|
|
+ if (/\d{16,}/.test(str)) {
|
|
|
+ let replaceMap = [];
|
|
|
+ let n = 0;
|
|
|
+ str = str.replace(/"(\\?[\s\S])*?"/g, function (match) {
|
|
|
+ if (/\d{16,}/.test(match)) {
|
|
|
+ replaceMap.push(match);
|
|
|
+ return '"""';
|
|
|
+ }
|
|
|
+ return match;
|
|
|
+ }).replace(/[+\-\d.eE]{16,}/g, function (match) {
|
|
|
+ if (/^\d{16,}$/.test(match)) {
|
|
|
+ return '"' + match + '"';
|
|
|
+ }
|
|
|
+ return match;
|
|
|
+ }).replace(/"""/g, function () {
|
|
|
+ return replaceMap[n++];
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return JSON.parse(str);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|