SyntaxError: Unexpected end of JSON input

hanaphouse
Giga Guru

I am getting this error on the Chrome Console:

find_real_file.png

My script is:

function onChange(control, oldValue, newValue, isLoading) {
	
	console.log('current.variables.mrvs_set_1: ' + g_form.getValue('mrvs_set_1'));
	console.log('current.variables.mrvs_set_1_json: ' + JSON.parse(g_form.getValue('mrvs_set_1')));
	
}

 

Upon further checking, getValue returns a string and if you do a JSON.parse on this string, the error comes up. What am I missing? I want to use the MRVS data for a REST method that I will invoke for a 3rd-party system. Any thoughts?

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Your script seems correct.

Are you sure the mrvs_set_1 is the name of your variable?

Is there another variable or variable set with the same name?

 

Can you share the console.log messages?

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

Can you try 

 

function onChange(control, oldValue, newValue, isLoading) {
	
	console.log('current.variables.mrvs_set_1: ' + g_form.getValue('mrvs_set_1'));
	console.log('current.variables.mrvs_set_1_json: ' + JSON.parse(JSON.stringify(g_form.getValue('mrvs_set_1'))));
	
}

Please mark this response as correct or helpful if it assisted you with your question.

Willem
Giga Sage
Giga Sage

Your script seems correct.

Are you sure the mrvs_set_1 is the name of your variable?

Is there another variable or variable set with the same name?

 

Can you share the console.log messages?

Thank you. I have checked that and you are correct, it is different.