I've retrieved a JSON response from an external API and one of the variable names begins with a # character, so the JSON variable looks like this #text. Unfortunately angular doesn't know how to handle this variable, is there any way delete the # so that the data assigned to the identifier is usable.

            Asked
            
        
        
            Active
            
        
            Viewed 115 times
        
    0
            
            
         
    
    
        William Lake.
        
- 81
- 7
- 
                    2What do you mean "angular doesn't know how to handle it?" That could mean a number of things, but what I think you mean is that _you_ don't know how to handle it. Don't use the dot notation, use the bracket notation to reference it, like `object['#text']` instead of `object.#text` – Patrick Roberts Sep 17 '17 at 08:06
- 
                    Yeah, I didn't know how to handle it, this is the correct answer. – William Lake. Sep 17 '17 at 08:17
3 Answers
1
            In order to reference a property that does not follow the rules for a properly formatted identifier, you must use bracket notation instead of dot notation for the property accessor:
var object = JSON.parse('{"#text":"https://lastfm-im...png","size":"extralarge"}')
console.log(object['#text']) 
    
    
        Patrick Roberts
        
- 49,224
- 10
- 102
- 153
0
            
            
        you cam modifide the response - loop throw it wite map- and chenge the object key -see here: JavaScript: Object Rename Key
 
    
    
        yanai edri
        
- 359
- 2
- 4
0
            
            
        You can use square bracket notation instead of dot notation. like (Object mutation is highly not recommended)
//to access it u can use square bracket notation like k["objectname"]
let k = {"#test":"some data"}
 alert("data is "+k["#test"]) 
    
    
        karthik
        
- 1,100
- 9
- 21