Я работаю с приложением AngularJs.
Я получаю некоторые данные из серверной части в кодированном формате Base64.
Когда я пытаюсь декодировать данные, я получаю данные в текстовом формате (безлюбая кавычка).
Следовательно, я не могу отобразить данные (они становятся неопределенными)
Есть ли способ преобразовать текст в строку?
Здесьмой код:
//Encoded data
templateData.content = "U1lOVEFYX1ZFUlNJT04gMTMKCkdFTkVSSUNfU09VUkNFICJTeXNfU3lzbG9nU3RyZWFtaW5nIgpERVNDUklQVElPTiAiVGhpcyBwb2xpY3kgbm9ybWFsaXplcyB0aGUgc3lzbG9nIG1lc3NhZ2VzIGFuZCBjb3ZlcnRzIHRvIEpTT04gZGF0YS4KVGhlIGxpc3Qgb2YgbG9nIGZpbGVzIGFyZSByZWFkIGZyb20gJy9ldGMvcnN5c2xvZy5jb25mJyBvciAnL2V0Yy9zeXNsb2cuY29uZicgKGJhc2VkIG9uIHRoZSBPUywgdmVyc2lvbikuCkZvciBlLmcuIFwiL3Zhci9sb2cvbWVzc2FnZXNcIiwgXCIvdmFyL2xvZy9jcm9uXCIsIFwiL3Zhci9sb2cvbWFpbGxvZ1wiIgpQT0xUWVBFICJnZW5vdXRzdHJ1bG8iCiAgIEdST1VQICJST09UIgogICAgICBHUk9VUCAiY29udGVudCIKICAgICAgICAgR1JPVVAgIm9wdGlvbnMiCiAgICAgICAgIEdST1VQX0VORAogICAgICAgICBHUk9VUCAic291cmNlcyIKICAgICAgICAgICAgR1JPVVAgIktFWU1BUFJVTEUiCiAgICAgICAgICAgICAgIFBBUkFNICJLRUVQX0lOUFVUX0ZJRUxEUyIgICIwIgogICAgICAgICAgICAgICBHUk9VUCAiS0VZRklFTERfTUFQUElOR1MiCiAgICAgICAgICAgICAgICAgIFBBUkFNICJLRl9NQVAiICAiS0VFUCIKICAgICAgICAgICAgICAgICAgQVRUICJLRVlfSU4iICAibG9nX2hvc3RuYW1lIgogICAgICAgICAgICAgICAgICBBVFQgIktFWV9PVVQiICAibG9nX2hvc3RuYW1lIgogICAgICAgICAgICAgICAgICBQQVJBTSAiS0ZfTUFQIiAgIktFRVAiCiAgICAgICAgICAgICAgICAgIEFUVCAiS0VZX0lOIiAgIm1lc3NhZ2UiCiAgICAgICAgICAgICAgICAgIEFUVCAiS0VZX09VVCIgICJtZXNzYWdlIgogICAgICAgICAgICAgICBHUk9VUF9FTkQKICAgICAgICAgICAgICAgR1JPVVAgIkFERElUSU9OQUxfRklFTERTIgogICAgICAgICAgICAgICAgICBQQVJBTSAiQUREX0ZJRUxEIiAgIkFERCIKICAgICAgICAgICAgICAgICAgQVRUICJOQU1FIiAgInRpbWVzdGFtcCIKICAgICAgICAgICAgICAgICAgQVRUICJWQUxVRSIgICIkWVlZWS08JE1BUChtYXBtb250aCw8JERBVEE6bW9udGg+KT4tPCREQVRBOmRhdGU+IDwkREFUQTp0aW1lPiRUSU1FWk9ORSIKICAgICAgICAgICAgICAgICAgUEFSQU0gIkFERF9GSUVMRCIgICJBREQiCiAgICAgICAgICAgICAgICAgIEFUVCAiTkFNRSIgICJkZXZpY2VfdmVuZG9yIgogICAgICAgICAgICAgICAgICBBVFQgIlZBTFVFIiAgIkluZnJhc3RydWN0dXJlIgogICAgICAgICAgICAgICAgICBQQVJBTSAiQUREX0ZJRUxEIiAgIkFERCIKICAgICAgICAgICAgICAgICAgQVRUICJOQU1FIiAgImRldmljZV9wcm9kdWN0IgogICAgICAgICAgICAgICAgICBBVFQgIlZBTFVFIiAgInN5c2xvZyIKICAgICAgICAgICAgICAgICAgUEFSQU0gIkFERF9GSUVMRCIgICJBREQiCiAgICAgICAgICAgICAgICAgIEFUVCAiTkFNRSIgICJkZXZpY2VfdmVyc2lvbiIKICAgICAgICAgICAgICAgICAgQVRUICJWQUxVRSIgICIxIgogICAgICAgICAgICAgICAgICBQQVJBTSAiQUREX0ZJRUxEIiAgIkFERCIKICAgICAgICAgICAgICAgICAgQVRUICJOQU1FIiAgInNldmVyaXR5IgogICAgICAgICAgICAgICAgICBBVFQgIlZBTFVFIiAgIk1lZGl1bSIKICAgICAgICAgICAgICAgICAgUEFSQU0gIkFERF9GSUVMRCIgICJBREQiCiAgICAgICAgICAgICAgICAgIEFUVCAiTkFNRSIgICJob3N0bmFtZSIKICAgICAgICAgICAgICAgICAgQVRUICJWQUxVRSIgICIkSE9TVE5BTUUiCiAgICAgICAgICAgICAgICAgIFBBUkFNICJBRERfRklFTEQiICAiQUREIgogICAgICAgICAgICAgICAgICBBVFQgIk5BTUUiICAicGF0aCIKICAgICAgICAgICAgICAgICAgQVRUICJWQUxVRSIgICIkTE9HU09VUkNFIgogICAgICAgICAgICAgICBHUk9VUF9FTkQKICAgICAgICAgICAgR1JPVVBfRU5ECiAgICAgICAgICAgIFBBUkFNICJsb2dwYXRoIiAgIjxgaXNwaS1vdnBlcmwgZ2V0U3lzbG9nUGF0aC5wbGA+JSVoZWxsbyUlIgogICAgICAgICAgICBQQVJBTSAiaW50ZXJ2YWwiICAiMW0wcyIKICAgICAgICAgICAgUEFSQU0gImNoU2V0IiAgIjY5IgogICAgICAgICAgICBQQVJBTSAicmVhZE1vZGUiICAiZnJvbUxhc3RQb3MiCiAgICAgICAgICAgIFBBUkFNICJub0xvZ2ZpbGVNc2ciICAiMSIKICAgICAgICAgICAgUEFSQU0gImNsb3NlQWZ0ZXJSZWFkIiAgIjEiCiAgICAgICAgICAgIFBBUkFNICJwYXR0ZXJuIiAgIl48MyoubW9udGg+WyAgfCBdPCMuZGF0ZT4gPEAudGltZT4gPEAubG9nX2hvc3RuYW1lPiA8Ki5tZXNzYWdlPiIKICAgICAgICAgICAgR1JPVVAgInN0YXJ0UGF0dGVybnMiCiAgICAgICAgICAgIEdST1VQX0VORAogICAgICAgICBHUk9VUF9FTkQKICAgICAgR1JPVVBfRU5ECiAgIEdST1VQX0VORAoKICAgICAgICBNQVAgIm1hcG1vbnRoIgogICAgICAgIERFU0NSSVBUSU9OICIiCiAgICAgICAgSU5QVVQgIjwkREFUQTptb250aD4iCiAgICAgICAgICBGUk9NICJKYW4iIFRPICIwMSIKICAgICAgICAgIEZST00gIkZlYiIgVE8gIjAyIgogICAgICAgICAgRlJPTSAiTWFyIiBUTyAiMDMiCiAgICAgICAgICBGUk9NICJBcHIiIFRPICIwNCIKICAgICAgICAgIEZST00gIk1heSIgVE8gIjA1IgogICAgICAgICAgRlJPTSAiSnVuIiBUTyAiMDYiCiAgICAgICAgICBGUk9NICJKdWwiIFRPICIwNyIKICAgICAgICAgIEZST00gIkF1ZyIgVE8gIjA4IgogICAgICAgICAgRlJPTSAiU2VwIiBUTyAiMDkiCiAgICAgICAgICBGUk9NICJPY3QiIFRPICIxMCIKICAgICAgICAgIEZST00gIk5vdiIgVE8gIjExIgogICAgICAgICAgRlJPTSAiRGVjIiBUTyAiMTIiCgogICAgICAgIERFRkFVTFRNU0cK";
//Decoding
data.content = Base64.decode(templateData.content);
console.log("data",data) // data { content: undefined }
После декодирования данные выглядят следующим образом:
SYNTAX_VERSION 13
GENERIC_SOURCE "Sys_SyslogStreaming"
DESCRIPTION "This policy normalizes the syslog messages and coverts to JSON data.
The list of log files are read from '/etc/rsyslog.conf' or '/etc/syslog.conf' (based on the OS, version).
For e.g. \"/var/log/messages\", \"/var/log/cron\", \"/var/log/maillog\""
POLTYPE "genoutstrulo"
GROUP "ROOT"
GROUP "content"
GROUP "options"
GROUP_END
GROUP "sources"
GROUP "KEYMAPRULE"
PARAM "KEEP_INPUT_FIELDS" "0"
GROUP "KEYFIELD_MAPPINGS"
PARAM "KF_MAP" "KEEP"
ATT "KEY_IN" "log_hostname"
ATT "KEY_OUT" "log_hostname"
PARAM "KF_MAP" "KEEP"
ATT "KEY_IN" "message"
ATT "KEY_OUT" "message"
GROUP_END
GROUP "ADDITIONAL_FIELDS"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "timestamp"
ATT "VALUE" "$YYYY-<$MAP(mapmonth,<$DATA:month>)>-<$DATA:date> <$DATA:time>$TIMEZONE"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "device_vendor"
ATT "VALUE" "Infrastructure"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "device_product"
ATT "VALUE" "syslog"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "device_version"
ATT "VALUE" "1.0"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "severity"
ATT "VALUE" "Medium"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "hostname"
ATT "VALUE" "$HOSTNAME"
PARAM "ADD_FIELD" "ADD"
ATT "NAME" "path"
ATT "VALUE" "$LOGSOURCE"
GROUP_END
GROUP_END
PARAM "logpath" "<`ispi-ovperl getSyslogPath.pl`>"
PARAM "interval" "1m0s"
PARAM "chSet" "69"
PARAM "readMode" "fromLastPos"
PARAM "noLogfileMsg" "1"
PARAM "closeAfterRead" "1"
PARAM "pattern" "^<3*.month>[ | ]<#.date> <@.time> <@.log_hostname> <*.message>"
GROUP "startPatterns"
GROUP_END
GROUP_END
GROUP_END
GROUP_END
MAP "mapmonth"
DESCRIPTION ""
INPUT "<$DATA:month>"
FROM "Jan" TO "01"
FROM "Nov" TO "11"
FROM "Dec" TO "12"
DEFAULTMSG
Значение которого становится неопределенным, поскольку angularjs не может распознать тип данных.
Я попытался метод toString.Также я попытался добавить кавычку вокруг.Но ничего не помогло.
Может кто-нибудь помочь мне преобразовать эти данные в строку?