如何在处理DB查询时模糊JSON响应? [英] How do obfuscate JSON response when dealing with a DB query?

查看:113
本文介绍了如何在处理DB查询时模糊JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[
 {
  "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"
 }
]

这个JSON编码响应在Chrome的控制台中显示。此数组是从数据库查询返回的。它显示我的表列名。出于安全原因,我不想显示我的表列名称。 如何对此JSON对象进行模糊处理或哈希和/或编码或动态重写以保持我的表格列名称不公开?

This JSON encode response is seen in console of Chrome. This array is being returned from a DB query. It is showing my table column names. For security reasons I do not want to show my table column names. How can this JSON object be obfuscated or hashed and/or encoded or dynamically re-written to keep my table col names private?

推荐答案

这取决于您收到记录后如何使用。一种策略可能是仅返回值的数组,丢弃密钥。然后在代码中,使用您在处理记录时需要的数据值的私有知识。类似:

It really depends on how you wish to use the record once it has been received. One strategy might be to return an array of the values only, discarding the keys. Then in your code, use your private knowledge of which array value you need when you process 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.

这篇关于如何在处理DB查询时模糊JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆