YangYoona 2017-08-03 08:29 采纳率: 5.6%
浏览 1214

javascript浏览器控制台读取JSON的问题

我想读取的数据的网址是百度云上身份证识别的一个地址:
https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=24.3074598030d473298e5197a463dd4a7f.2592000.1504252081.282335-9863126

需要传上的参数是:
id_card_side:front(代表身份证正面)back(代表身份证反面)
image:【图片Base64编码,需encodeURIComponent()】

正常访问参数传正确的数据:
{
"log_id": 525464404,
"words_result_num": 6,
"image_status": "normal",
"words_result": {
"住址": {
"location": {
"width": 337,
"top": 320,
"height": 75,
"left": 176
},
"words": "山东省五莲县城关沿河路398号6号楼3单元205室"
},
"出生": {
"location": {
"width": 0,
"top": 0,
"height": 0,
"left": 0
},
"words": "19871116"
},
"姓名": {
"location": {
"width": 92,
"top": 91,
"height": 33,
"left": 183
},
"words": "权志龙"
},
"公民身份号码": {
"location": {
"width": 444,
"top": 512,
"height": 32,
"left": 341
},
"words": "371121198711160018"
},
"性别": {
"location": {
"width": 0,
"top": 0,
"height": 0,
"left": 0
},
"words": "男"
},
"民族": {
"location": {
"width": 23,
"top": 169,
"height": 28,
"left": 391
},
"words": "汉"
}
}
}

我需要识别出来的数据,js的代码怎么去写呢?

  • 写回答

3条回答

  • meicuojiushiwoi 2017-08-03 08:47
    关注

    假如获取的数据名称为data且是字符串格式,要把data转为json对象,用eval('('+data+')')就可以转为对象,接着要获取log_id直接就是data.log_id,如果是住址下面的words就是data.words_result.words

    评论

报告相同问题?

悬赏问题

  • ¥15 overleaf中论文编辑,报错`pages' is a missing field, not a string, for entry 4
  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么