Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        5年前关闭。
                                                                                            
                
        
所以我有一个字符串常量

MyString.START = 'start';


我有一个需要解析的JSON,让我们称之为输入

我想说input[MyString.START]

语法看起来像什么?

最佳答案

var MyString = {};
MyString.START = 'start';

var json = '{"start": 1,"prop2": 2}';
var obj = JSON.parse(json);

console.log(obj[MyString.START]); // prints 1

07-28 11:28