我想将json通过jackson库转换为包含camelCase键的地图......说...
从
{
"SomeKey": "SomeValue",
"AnotherKey": "another value",
"InnerJson" : {"TheKey" : "TheValue"}
}
Run Code Online (Sandbox Code Playgroud)
对...
{
"someKey": "SomeValue",
"anotherKey": "another value",
"innerJson" : {"theKey" : "TheValue"}
}
Run Code Online (Sandbox Code Playgroud)
我的代码......
public Map<String, Object> jsonToMap(String jsonString) throws IOException
{
ObjectMapper mapper=new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
return mapper.readValue(jsonString,new TypeReference<Map<String, Object>>(){});
}
Run Code Online (Sandbox Code Playgroud)
但是这不起作用......甚至其他的propertyNamingStrategy也无法在json上运行...比如......
{
"someKey": "SomeValue"
}
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.PascalCaseStrategy())
Run Code Online (Sandbox Code Playgroud)
至
{
"SomeKey": "SomeValue"
}
Run Code Online (Sandbox Code Playgroud)
如何通过jackson获取camelCase Map键名...或者我应该手动循环映射和转换键还是有其他方法???
提前致谢...
我是一名新程序员,目前正在学习php mvc.我正在从头开始构建一个框架/ mvc系统......现在我遇到了.htaccess的问题.
example.com = localhost // unable to post question for localhost link
Run Code Online (Sandbox Code Playgroud)
我的申请网址是这样的......
http://example.com/mvc/index.php?go=test //test is a controller's name
在.htaccess的帮助下,我清理了网址....
http://example.com/mvc/test
如果控制器不存在,则显示错误视图,其中包含一些错误消息.
http://example.com/mvc/doesnotexistsRun Code Online (Sandbox Code Playgroud) 但是如果我把"/"(正斜杠)放在网址中...... http://example.com/mvc/test/Run Code Online (Sandbox Code Playgroud) 它显示错误但不加载任何css或js文件.
我还在网址中包含了控制器方法......
http://example.com/mvc/test/viewresultRun Code Online (Sandbox Code Playgroud) 如果在该控制器中找不到匹配的方法显示错误消息,则显示但是同样的问题...没有css也没有js.
如果我通过完整网址,我已经完全加载了css和js
http://example.com/mvc/index.php?go=doesnotexists/Run Code Online (Sandbox Code Playgroud) 等等
我已经尝试了几个.htaccess规则,但无法让它工作.请提前帮助和感谢..我的currrent .htaccess代码......
<IfModule mod_rewrite.c>
# Turn on
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
#RewriteCond %{REQUEST_URI} !^/assets/
#RewriteCond $1 !^(favicon\.ico|favicon\.png|media|robots\.txt|crossdomain\.xml|.*\.css|.*\js)
RewriteRule ^(.+)$ index.php?go=$1 [QSA,L]
# Generic 404 for anyplace on the site
# ...
</IfModule>
Run Code Online (Sandbox Code Playgroud) 我是Java和mybatis3的新手.在一个项目我使用mybatis3 ..
说我有名为"t"的数据库表.有几列.
在项目中,我将向mapper.xml发送一个hashmap(包含2个keyList的值,值).从那里它将获得2个数组包含列名称的键和列的值...
我想插入那个表...我认为我能够动态插入数据并部分更新一些列数据...更新...但是得到sql语法错误...
我现有的mapper.xml代码
<insert id="createNews" parameterType="map" useGeneratedKeys="true" keyColumn="id">
INSERT INTO t
<foreach item="key" collection="Key" index="index" open="(" separator="," close=")">
#{key}
</foreach>
VALUES
<foreach item="value" collection="Value" index="index" open="(" separator="," close=")">
#{value}
</foreach>
;
</insert>
Run Code Online (Sandbox Code Playgroud)
部分错误stackTrace ....
### Error updating database. Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''name'
)
VALUES
(
'some value'
' at line 3
Run Code Online (Sandbox Code Playgroud)
但是,当我对列名进行硬编码时,它的工作正常...如何动态插入...
注意:我用Google搜索,但无法找到...我不想使用任何pojo或注释...在此先感谢...