How to read attribute from JSON if an identifier starts with a number

Vijay Kumar21
Tera Contributor

Hi Team,

 

I am trying to read an attribute(1star) from the below JSON from the POST API.

 

{
  "account": {
    "1star": "1000094"
  }
}

 

When I try to read this attribute it shows an error 'parsing error: identifier directly after number'

 

I am trying to read it like this - var account1star_number = account.1star;

 

error1.png

how to solve this error?

 

1 ACCEPTED SOLUTION

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
Run below in background-

var t={
  "account": {
    "1star": "1000094"
  }
}

gs.info(t['account']['1star'])




Thanks and Regards,

Saurabh Gupta

View solution in original post

1 REPLY 1

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
Run below in background-

var t={
  "account": {
    "1star": "1000094"
  }
}

gs.info(t['account']['1star'])




Thanks and Regards,

Saurabh Gupta