나는 복잡한 XML 파일로 많은 작업을 요구하므로 SimpleXML 배열, JSON으로 변환하고 Ajax를 통해 Knockout으로 전달합니다.KnockoutJS : 불법적 인 이름을 가진 객체에 바인딩
문제는 각각의 속성이 속성을 가지고 있기 때문에 SimpleXML이 @attributes
이라는 객체를 사용한다는 것입니다. 내가 myObject()[email protected]
처럼 결합 할 때, 나는 '@attributes', ['@attributes'], [@attributes]
을 시도했지만 아무것도 작동하지
Message: SyntaxError: Unexpected token ILLEGAL;
Bindings value: text: alertObj()[email protected]
오류를 얻을. 나는 또한 다양한 이스케이프 문자와 유니 코드 이스케이프를 시도했다. 내가 어떤 식 으로든 구조와 이름을 변경하지 않도록하고 싶습니다
var alertObject =
{
"@attributes":
{
"DescriptionContentType":"text\/plain",
"Description":"",
"IsActive":"true",
"Name":"Apache Requests Per Interval"
},
"Frequency":
{
"PeriodInSeconds":"60"
},
"MetricLevelNotification":"false",
"AlertTriggerMode":"2",
"CautionActionDelay":"0",
"DangerActionDelay":"0",
"CautionActionList":
{
"ActionID":
{
"ManagementModuleName":"Base Module",
"ConstructName":"Base SMTP Mail Action"
}
},
"DangerActionList":
{
"ActionID":
{
"ManagementModuleName":"Base Module",
"ConstructName":"Base SMTP Mail Action"
}
},
"MetricGroupingID":
{
"ManagementModuleName":"Base Module",
"ConstructName":"Apache Requests Per Interval"
},
"AlertCombineOperator":"1",
"AlertCompareOperator":"2",
"CautionTargetValue":"2000",
"DangerTargetValue":"15000",
"CautionMinNumPerPeriod":"3",
"CautionAlertPeriod":"6",
"DangerMinNumPerPeriod":"1",
"DangerAlertPeriod":"1"
};
:
는이 같은 JSON 보이는 것입니다.
어떻게하면 되나요? 유효한 자바 스크립트 변수 이름이 아니므이다
이는 의미가 있습니다. 나는 json을 인코딩하기 전에 서버 측에서 배열을 변경할 것이다. 감사. – solefald