我在使用jackson-core-2.7.3.jar解析JSON时遇到问题你可以从这里得到它们http://repo1.maven.org/maven2/com/fasterxml/jackson/core/
我的JSON文件是
[
{
"Name": "System Idle Process",
"CreationDate": "20160409121836.675345+330"
},
{
"Name": "System",
"CreationDate": "20160409121836.675345+330"
},
{
"Name": "smss.exe",
"CreationDate": "20160409121836.684966+330"
}
]
Run Code Online (Sandbox Code Playgroud)
而Java代码是我试图解析的
byte[] mapData = Files.readAllBytes(Paths.get("process.txt"));
Map<String,String> myMap = new HashMap<String, String>();
ObjectMapper objectMapper=new ObjectMapper();
myMap = objectMapper.readValue(mapData, HashMap.class);
System.out.println("Map is: "+myMap);
Run Code Online (Sandbox Code Playgroud)
但在执行时我收到了错误
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token
at [Source: [B@34ce8af7; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:216)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:873)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:869)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:874)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:337)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789)
at …Run Code Online (Sandbox Code Playgroud) 我面临Ajax的奇怪问题我已经尝试检查所有代码但仍然使用GET方法而不是POST.如果我错了,请更正以下这是我的代码
$(document).ready(function(){
$("#err<?php echo $id; ?>").css('display', 'none', 'important');
$("#submit-edit<?php echo $id; ?>").click(function(){
$.ajax({
type: "POST",
url: "includes/edit_user.php",
data: "submit-edit="+$("#submit-edit<?php echo $id; ?>").val()+"&user_id="+$("#user_id").val()+"&username="+$("#username").val()+"&password="+$("#password").val()+"&firstname="+$("#firstname").val()+"&lastname="+$("#lastname").val(),
success: function(html){
if($.trim(html)=='true') {
$("#err<?php echo $id; ?>").addClass("alert alert-success err-inline");
$("#err<?php echo $id; ?>").html("<strong>User Details are Updated Successfully</strong>");
window.location="<?php basename($_SERVER['PHP_SELF']); ?>";
}
else {
$("#err<?php echo $id; ?>").addClass("alert alert-danger err-inline");
$("#err<?php echo $id; ?>").html("<img src='images/caution-icon.png' /> <strong>Please check the details you have entered</strong>");
}
},
beforeSend:function()
{
$("#err<?php echo $id; ?>").css('display', '-webkit-inline-box', 'important');
$("#err<?php echo $id; ?>").addClass("err-inline");
$("#err<?php …Run Code Online (Sandbox Code Playgroud)