0

要在 SQL 适配器中构造 JSON 对象,我尝试了以下方法:

{
    'PatientID':4, 
    'FName':'test',
    'LName':'test',
    'AGE':1,
    'DOB':1988-09-01,
    'GENDER':'m',
    'BG':'A+'
}

但是我收到一个错误:

{
   "errors": [
      "Runtime: Method createSQLStatement was called inside a JavaScript function."
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}


全尺寸图片
如何在 IBM Worklight 的 sql Adapter 中构造 Json oblect

4

2 回答 2

2

First, in the "Invoke Procedure Data" window for your adapter, don't wrap the object in quotes. If you do, it will think that the entire thing is a string.

If you remove the beginning and ending quotes then you almost have it correct. The window will take valid JSON objects, but only if all non integers are strings. Since 1988-09-01 is not a valid integer, it must be wrapped in quotes. You should be able to copy/paste this object into the wizard:

{
    'PatientID':4, 
    'FName':'test',
    'LName':'test',
    'AGE':1,
    'DOB':"1988-09-01",
    'GENDER':'m',
    'BG':'A+' 
}
于 2013-07-18T19:48:30.343 回答
0

不应在函数内部使用 createSQLStatement API。你在函数之外,就像教程展示(幻灯片 10)http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v600/04_03_SQL_adapter_-_Communicating_with_SQL_database.pdf

于 2013-07-18T20:33:44.243 回答