Unable to fetch the key value for JSON parsed in Javascript getting undefined message

Vineela1
Tera Contributor

Hi Team,

 

Please suggest inputs, I have javascript variable which I made stringify() to convert to javascript string and made JSON.parse() . When I am trying to fetch the key value it is showing undefined message but that value exist in JSON object.

example:

obj = {

   "budget": "value",

   "cost":"value"

}

when I am trying to access budget value. It shows me undefined . Please suggest on this.

 

 

Thanks and Regards,

 

Vineela

1 ACCEPTED SOLUTION

I tried replicating same in my instance and it's a working script unless format of data structure do not changes. Below the screen shots :

kamleshkjmar_2-1666969437777.png

 

 

kamleshkjmar_1-1666969405472.png

 

If this still do not works please share the screen shot of field and value it's storing. Like the one of description I have shown. Most probably then the issue is with the data stored.

 

Regards,

Kamlesh 

View solution in original post

15 REPLIES 15

Hi Kamlesh,

While passing the value, removed " ; " in the custom_field .

 

Regards,

Vineela

I tried replicating same in my instance and it's a working script unless format of data structure do not changes. Below the screen shots :

kamleshkjmar_2-1666969437777.png

 

 

kamleshkjmar_1-1666969405472.png

 

If this still do not works please share the screen shot of field and value it's storing. Like the one of description I have shown. Most probably then the issue is with the data stored.

 

Regards,

Kamlesh 

Hi Kamlesh,

Great! Really Thanks for your inputs . issue solved. Getting expected response.

I have changed the JSON Input value format also. It is working fine now. 🙂

 

Like this . {"budget":"value","jobid":"value","location":"value", "plbs":"value"}

 

Regards,

Vineela

Hi @Vineela1 

As per the other conversations I don't think it doesn't matter about the ;

Because you can below outputs as per our JSON data in your actual question:

MurthyCh_0-1667031410574.png

Output:

MurthyCh_1-1667031423873.png

Hope it's clear...

 

 

Thanks,
Murthy

sree44
Tera Contributor

Use 

var obj1 = JSON.stringify(obj.budget);
gs.info(obj1);