Issues in parsing Json content which contains Javascript code in it

We are facing some issues in parsing a JSON content. We are using JSONPlus parser (a free plugin available in the net) to parse the JSON content. JSON contains the data/information to populate a Kendo Pivot grid. In the Json we have some columns named as calculated columns which contains the javascript code which is dynamically rendered to the Kendo Pivot grid. Strangely the parsing works fine when it is limited to 5 columns and when we have more that 5 columns it tend to break i.e. it doesn’t parse it correctly.

Please find the sample JSON which we are trying to parse and facing the issues. The calculated columns which I mentioned here are “Calc1, Calc2…Calc6,Calc7” which are nothing but a javascript code. The problem appears when we add column Calc6 & 7.

{
“filterable”: true,
“sortable”: true,
“columnWidth”: 120,
“height”: 570,
“dataCellTemplate”: “# if (measure.name==‘Sold Dollars’) { ## var value = kendo.format(’{0:n0}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc1’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc2’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc3’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc4’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc5’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc6’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else if (measure.name==‘Calc7’) { ## var value = kendo.format(’{0:n2}’, dataItem.value); ##: value ## } else { # # var value = kendo.format(’{0:n}’, dataItem.value); ##: value ## } #”,
“columnHeaderTemplate”: “”,
“rowHeaderTemplate”: “”,
“dataSource”: {
“schema”: {
“model”: {
“fields”: [
{
“name”: “Sold_Dollars”
},
{
“name”: “Brand”
},
{
“name”: “Retailer_Name”
},
{
“name”: “bsFnXCalc1”
},
{
“name”: “bsFnXCalc2”
},
{
“name”: “bsFnXCalc3”
},
{
“name”: “bsFnXCalc4”
},
{
“name”: “bsFnXCalc5”
},
{
“name”: “bsFnXCalc6”
},
{
“name”: “bsFnXCalc7”
}
]
},
“cube”: {
“dimensions”: {
“Brand”: {
“caption”: “Brand”
},
“Retailer_Name”: {
“caption”: “Retailer Name”
}
},
“measures”: {
“Sold Dollars”: {
“field”: “Sold_Dollars”,
“format”: “{0:n0}”,
“aggregate”: “sum”
},
“Calc1”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc1=state.Sold_Dollars1;
},
“result”: function(state){
returnstate.Calc1;
}
},
“Calc2”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc2=state.Sold_Dollars
2;
},
“result”: function(state){
returnstate.Calc2;
}
},
“Calc3”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc3=state.Sold_Dollars3;
},
“result”: function(state){
returnstate.Calc3;
}
},
“Calc4”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc4=state.Sold_Dollars
4;
},
“result”: function(state){
returnstate.Calc4;
}
},
“Calc5”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc5=state.Sold_Dollars5;
},
“result”: function(state){
returnstate.Calc5;
}
},
“Calc6”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc6=state.Sold_Dollars
6;
},
“result”: function(state){
returnstate.Calc6;
}
},
“Calc7”: {
“format”: “{0:n2}”,
“aggregate”: function(value,
state,
context){
vardataItem=context.dataItem;varSold_Dollars=dataItem.Sold_Dollars;state.Sold_Dollars=(state.Sold_Dollars||0)+Sold_Dollars;state.Calc7=state.Sold_Dollars*7;
},
“result”: function(state){
returnstate.Calc7;
}
}
}
}
},
“rows”: [
{
“name”: “Retailer_Name”,
“expand”: true
},
{
“name”: “Brand”,
“expand”: true
}
],
“measures”: [
“Sold Dollars”,
“Calc1”,
“Calc2”,
“Calc3”,
“Calc4”,
“Calc5”,
“Calc6”,
“Calc7”
]
}
}
Please find the snapshot which specifies about the problem i.e. breakage in the parsed content of Json.


Note: when we try the same application with less than 5 columns i.e upto “Calc1, Calc2…Calc5”, the json parsing happens properly and the application works fine.

any ideas why this issues happens during parsing? Is there any issues in the Json content?

This forum is for discussing the JSONAPI specification, not general JSON or API issues. Please follow up in a Kendo-specific forum.