Revision 61031
Added by Alessia Bardi almost 3 years ago
JsonUtilsTest.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.collector.plugins.utils; |
2 | 2 |
|
3 |
import com.google.gson.Gson; |
|
3 | 4 |
import org.junit.Before; |
4 | 5 |
import org.junit.Test; |
5 | 6 |
|
7 |
import java.util.Map; |
|
8 |
|
|
6 | 9 |
public class JsonUtilsTest { |
7 | 10 |
|
8 | 11 |
private JsonUtils utils; |
... | ... | |
17 | 20 |
String json = "{\"field1\":\"value1\", \"field2\":2}"; |
18 | 21 |
System.out.println(utils.convertToXML(json)); |
19 | 22 |
} |
23 |
|
|
24 |
@Test |
|
25 |
public void testConvertMap(){ |
|
26 |
Gson gson = new Gson(); |
|
27 |
Map<String, String> requestHeaders = gson.fromJson((String) null, Map.class); |
|
28 |
System.out.println(requestHeaders); |
|
29 |
for(String s : requestHeaders.keySet()){ |
|
30 |
System.out.println(requestHeaders.get(s)); |
|
31 |
} |
|
32 |
} |
|
20 | 33 |
} |
Also available in: Unified diff
REST plugin accepts optional Request Headers parameters as json map, e.g. {Accept:application/json}. This is useful to support PostgREST endpoints: they need a param in the header to return proper json. request headers must also be exploited for the pagination (not implemented in this commit). More details on PostgREST at https://postgrest.org/en/stable/api.html.
This commit also include minor refactoring