Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 读取REST服务中未知对象的数组_Java_Rest_Cxf - Fatal编程技术网

Java 读取REST服务中未知对象的数组

Java 读取REST服务中未知对象的数组,java,rest,cxf,Java,Rest,Cxf,如何为下面的数据POST请求编写REST服务?模板可以有任何数据,基本上是数据数组 { "name":"Jose", "surname":"John", "templates":[ { "template1":"333", "any":"any" }, { "anything":"anything", "test":"tafsasdf" } ] } C

如何为下面的数据POST请求编写REST服务?模板可以有任何数据,基本上是数据数组

{
   "name":"Jose",
   "surname":"John",
   "templates":[
      {
         "template1":"333",
         "any":"any"
      },
      {
         "anything":"anything",
         "test":"tafsasdf"
      }
   ]
}

CXF
知道如何将此类字符串转换为嵌套的
映射。您需要在类路径中包含
jackson
库,并使用
@RequestBody
注释服务器方法

大概是这样的:

@RequestBody
public void someMethod(Map<String, Object> json objects) { 
    // Code here
}
@RequestBody
公共方法(映射json对象){
//代码在这里
}

您如何在服务器部件上接收json?作为字符串,还是作为对象?您正在使用哪些LIB?请提供有关您使用的技术的更多信息。另外,这一点非常重要,告诉我们你尝试了什么,如果你被卡住了,告诉我们在哪里。