How to obfuscate a JSON response when working with a database query?

[ { "businesscards_id":"12", "X_SIZE":"1.75x3", "X_PAPER":"14ptGlossCoatedCoverwithUV(C2S)", "X_COLOR":"1002", "X_QTY":"250", "O_RC":"NO", "F_PRICE":"12490", "UPS_GROUND":"12000", "UPS_TWODAY":"24000", "UPS_OVERNIGHT":"36000" } ] 

This JSON encoding response is displayed in the Chrome console. This array is returned from the database query. It shows the column names of the table. For security reasons, I do not want to show the column names of the table. How can this JSON object be confused or hashed and / or encoded or dynamically rewritten to preserve personal table names?

+1
source share
3 answers

It really depends on how you want to use the record after receiving it. One strategy may be to return only an array of values, discarding keys. Then, in your code, use your personal knowledge of what array value you need when processing the record. Something like:

 var result=[]; Object.keys(record).forEach(function(key){result.push(record[key]);}); 

And then in your code, use array indices to access the values.

+1
source

Do nothing for your JSON.

If you do not want your column names to be visible, just do not use column names. Create a new array using the new keys to send using JSON, and then change this array to one containing the column names.

But this really should not be a problem when people see them. No one has access to your database, so letting people see column names is not a problem.

+5
source

SQL statement:

 SELECT `col_name` AS 'something_else' 

But, like everyone else, do not do this for safety. It's pointless.

+1
source

All Articles