小编Giy*_*ose的帖子

JSONObject排序的映射参数

我有一个Map,它包含String键和String和整数值.我将值放入地图中,如下所示:

Map map = new LinkedHashMap();
map.put("b", 1);
map.put("a", 2);
Run Code Online (Sandbox Code Playgroud)

在此之后,我将地图添加到List中:

List out = new LinkedList();
out.add(map);
Run Code Online (Sandbox Code Playgroud)

之后,我创建了一个JSONObject并将List放入其中:

org.json.JSONObject json = new org.json.JSONObject();
json.put("header", "header");
json.put("array", out);
Run Code Online (Sandbox Code Playgroud)

但如果我这样做,我会看到这个json结构:

{"header":"header","array":[{"a":2,"b":1}]}

但我想看到:

{ "头": "首部", "阵列":[{ "B":1, "A":2}]}

我哪里做错了?也许这不是正确的方法?

java json

5
推荐指数
1
解决办法
1181
查看次数

黄瓜PendingExceprion用于Intellij IDEA中的测试步骤

Erly我问 对黄瓜和java的问题.在纠正我的项目之后,我在cucumber-junit中检查了PendingException.我有两个类:TestClass.java用于使用SoapUI,TestSteps.java用于实现我的代码和JUnit Run.java类的黄瓜步骤.这是我的代码:TestClass.java:

    public class FirstTest {
private static String xmlFile;
private static String projectPath;

public FirstTest(String file)
{
    xmlFile = file;
}
//for Then step
public static void run() throws XmlException, IOException, SoapUIException {
    //add test project
    WsdlProject project = new WsdlProject(getProjectPath());
    //add xml file for test into property
    project.setPropertyValue("File", xmlFile);
    //get TestSuite and TestCase by name
    TestSuite testSuite = project.getTestSuiteByName("Test");
    TestCase testCase = testSuite.getTestCaseByName("Test");
    //run test
    testCase.run(new PropertiesMap(), false);

}

public static String getProjectPath()
{
    return projectPath …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea cucumber cucumber-jvm cucumber-junit

1
推荐指数
1
解决办法
9745
查看次数