Is it possible to hide the real column name from a table during json_encode time?

Tuesday, November 3, 2015

I am encoding a php array into json format which have data from a table.
My json_encode produces result with real column name of that table.I want to use the real column name in php side and after it encode to json format I will like to use some other custom name so, that if some user checks in .js file it won't be any problem for me.Below code is the result of json_encode.



What is now :-



{"result":[{"pals_id":"20","from_user":"hancy061","to_user":"hari061","username":"hancy061"} 


What I want :-



{"result":[{"pid":"20","fu":"hancy061","tu":"hari061","un":"hancy061"} 


Ya, there isn't any need to show user column name and it seems unsecure too.You guys can see what i want have the json_encode format which I want it to be.Is it possible from php side?I mean in php side before encoding the array into json format can we first make custom name of those columns?

0 comments:

Post a Comment