我有這個JSON負載,我想在幾個地方使用它,並想知道如何從這個拒絕兩個鍵。如何在jQuery中拒絕JSON密鑰?
@metaTagsAdvanced = {
App: { comparison: ['was', 'was not'], value: ['Opened in the last two days', 'Opened in the last two weeks', 'Opened in the last month'], enabled: true },
AppVersion: { comparison: ['equals', 'not equal', 'greater than', 'less than', 'greater than or equal', 'less than or equal'], value: 'string', enabled: true },
ControlGroup: { comparison: ['less than', 'less than or equal', 'greater than', 'greater than or equal', 'equals'], value: 'number', numberOptions: {min: 1, max: 10}, enabled: true },
Country: { comparison: ['is', 'is not'], value: 'country', enabled: true },
Deliverable: { comparison: ['is', 'is not'], value: ['Push Notification','Local Push Notification', 'App Originated Push', 'In-App Alert', 'In-App Content', 'SMS', 'MMS', 'Email', 'Rich Message'], enabled: true },
Event: {comparison: {eventNumber: ['did occur N days ago', 'did occur greater than N days ago','did occur greater than or equal to N days ago','did occur less than N days ago','did occur less than or equal to N days ago', 'did not occur N days ago','did not occur greater than N days ago','did not occur greater than or equal to N days ago','did not occur less than N days ago','did not occur less than or equal to N days ago'], standards: ['did occur', 'did not occur']}, value: 'events', enabled: true},
InstallDate: { comparison: ['before', 'was', 'after', 'within', 'days ago', 'greater than N days ago', 'greater than or equal to N days ago','less than N days ago', 'less than or equal to N days ago'], value: 'date', enabled: true },
Language: { comparison: ['is', 'is not'], value: 'language', enabled: true },
LastOpenDate: { comparison: ['before', 'was', 'after', 'within', 'N days ago', 'greater than N days ago', 'greater than or equal to N days ago', 'less than N days ago', 'less than or equal to N days ago'], value: 'date', enabled: true },
OS: { comparison: ['is', 'is not'], value: ['android', 'ios'], enabled: true },
PushOpenRate: { comparison: ['greater than or equal', 'less than or equal'], value: ['0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1'], enabled: true },
Segment: {comparison: ['is in'], value: 'segments', enabled: true},
Sessions: { comparison: ['less than', 'greater than'], value: 'number', numberOptions: {min: 1}, enabled: true },
Tag: {comparison: {string: ['is', 'is not', 'contains'], double: ['equals', 'not equal to', 'less than', 'greater than', 'less than or equal', 'greater than or equal'], timestamp: ['before', 'after', 'was', 'within', 'N days ago', 'greater than N days ago', 'greater than or equal to N days ago','less than N days ago','less than or equal to N days ago'], segment: ['is in', 'is not in'], standard: ['exists', 'does not exist']}, value: 'tags', enabled: true},
Timezone: {comparison: ['is', 'is not'], value: 'timezone', enabled: true}
}
所以我想插入實例,如下所示。但是,我怎麼能改變這段代碼來拒絕/排除上面的'Segment'和'Timezone'鍵?
filters = $.extend({}, @metaTagsAdvanced)
任何與此有關的幫助將不勝感激,因爲它可以讓我顯着重構我的一些代碼! (我用的CoffeeScript,因此爲什麼它的格式事情是這樣的!)
乾杯
爲什麼不簡單和刪除不需要的密鑰? O_O –
包含行'filters = $ .extend({},@metaTagsAdvanced)''的文件的文件名是什麼? – 7stud
它們都在同一個文件中,'filters = $ .extend({},@metaTagsAdvanced)'就在文件的後面。 – iamryandrake