issue in json ??

Hi I noticed a difference in the json behaviour between 5.2 and 7.3.1

If i Use :

globals.nav.programcheck = plugins.serialize.fromJSON(plugins.serialize.toJSON(globals.nav.program))

then in 5.2 globals.nav.programcheck and globals.nav.program are identical

If I do this in 7.3.1 they are not identical.

I also tried in 7.3.1

globals.nav.programcheck = JSON.parse(JSON.stringify(globals.nav.program))

, same issue

Is this a bug ??

Regards,

Hans

What is the actual difference?

And you should not use the serialize plugin if you just want to stringify/parse JavaScript objects, but use JSON instead

Paul

The first line of the original object is :

{Bcal_CustProblems:{add_mode:1,base_form_name:"bcal_navCustProblemsPrim",delete_mode:1,description:"Customer Problems",detail_form:1,display_field_header:"header_cust_problems",divider_height:420,divider_locked:0,edit_in_list:1,filter:,list_form:1,method:,method_types:{hasBrowse:{...},hasEdit:{...}},new_in_list:1,path:null,record_locking:0,record_locking_rels:null,relation:null,relation_form:Undefined,report:,report_types:{hasBrowse:{...},hasEdit:{...}},search_form:Undefined,sort_label:"Nummer",sort_value:"cstprpl_nr desc",sort_value_org:"cstprpl_nr desc",sortcriteria:,startup_view:"T",tab:[selected=1.0],table_form:1,table_tab_form:false,update_mode:1,view:"table"}

The first line of the object globals.nav.programcheck = JSON.parse(JSON.stringify(globals.nav.program))

{Bcal_CustProblems:{add_mode:1,base_form_name:"bcal_navCustProblemsPrim",delete_mode:1,description:"Customer Problems",detail_form:1,display_field_header:"header_cust_problems",divider_height:420,divider_locked:0,edit_in_list:1,filter:,list_form:1,method:,method_types:{hasBrowse:{...},hasEdit:{...}},new_in_list:1,path:null,record_locking:0,record_locking_rels:null,relation:null,report:,report_types:{hasBrowse:{...},hasEdit:{...}},sort_label:"Nummer",sort_value:"cstprpl_nr desc",sort_value_org:"cstprpl_nr desc",sortcriteria:,startup_view:"T",tab:,table_form:1,table_tab_form:false,update_mode:1,view:"table"}

As you can see one diff is that the first one containts : “relation_form:Undefined”, the second one does not.

I have uploaded both objects compleet versions

It seems that if there are undefined values in the object the line :

globals.nav.programcheck = JSON.parse(JSON.stringify(globals.nav.program))

will give a difference between globals.nav.programcheck and globals.nav.program

In servoy 5.2 this caused now issues.

I took care of those undefined values and after a quick test it seems to work now in 7.3.1.

I’ll have to test some more …

Regards,

Undefined/undefined is not a valid value in JSON, so that might be the cause of things.

If such entries remained while serializing back and forth objects previously, that would be a bug that is apparently now fixed.

Paul

Well, there is another issue if one of the values is an array :

original object first line :

 {Bcal_CustProblems:{add_mode:1,base_form_name:"bcal_navCustProblemsPrim",delete_mode:1,description:"Customer Problems",detail_form:1,display_field_header:"header_cust_problems",divider_height:420,divider_locked:0,edit_in_list:1,filter:,list_form:1,method:,method_types:{hasBrowse:{...},hasEdit:{...}},new_in_list:1,path:null,record_locking:0,record_locking_rels:null,relation:null,relation_form:null,report:,report_types:{hasBrowse:{...},hasEdit:{...}},search_form:null,sort_label:"Nummer",sort_value:"cstprpl_nr desc",sort_value_org:"cstprpl_nr desc",sortcriteria:,startup_view:"T",tab:[selected=1.0],table_form:1,table_tab_form:false,update_mode:1,view:"table"}

New objects first line after globals.nav.programcheck = JSON.parse(JSON.stringify(globals.nav.program))

 {Bcal_CustProblems:{add_mode:1,base_form_name:"bcal_navCustProblemsPrim",delete_mode:1,description:"Customer Problems",detail_form:1,display_field_header:"header_cust_problems",divider_height:420,divider_locked:0,edit_in_list:1,filter:,list_form:1,method:,method_types:{hasBrowse:{...},hasEdit:{...}},new_in_list:1,path:null,record_locking:0,record_locking_rels:null,relation:null,relation_form:null,report:,report_types:{hasBrowse:{...},hasEdit:{...}},search_form:null,sort_label:"Nummer",sort_value:"cstprpl_nr desc",sort_value_org:"cstprpl_nr desc",sortcriteria:,startup_view:"T",tab:,table_form:1,table_tab_form:false,update_mode:1,view:"table"}

As You can see in the first one the text “tab:[selected=1.0]” and the second line only has “tab:”

Regards,

Hans

What is the type of the value of the tab property?

It is part of the “old” servoy framework and defined as :

globals.nav.program[_rec.program_name].tab = new Array()
			globals.nav.program[_rec.program_name].tab.selected = 1
         		for (var j = 1; j <= _rec.program_to_programtabs.getSize(); j++) {
				globals.nav.program[_rec.program_name].tab[_tab_count] = new Object()
                                ......

Mmm, so that is an Array on which also a named property is set. I think it is logical that that is skipped in serialization, for sure when using JSON.

Again I think it is wrong that it worked in the past.

Paul