您好我需要生成具有特定格式的JSON文件。我陷入困境并建议如何继续这样做。我的代码如下:
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.io.FileWriter;
import java.io.IOException;
public class Student {
public static void main(String[] args) {
int a = -7;
int b = 7;
int k = 103;
int order = 109;
int px = 60;
int py = 76;
JSONObject obj = new JSONObject();
obj.put("name", "JEAN-LUC PALMYRE");
obj.put("srn", "120299364");
obj.put("ecc","");
try (FileWriter file = new FileWriter("Jean-LucPalmyre_120299364_CO3326_cw1.json"))
{
file.write(obj.toJSONString());
file.flush();
} catch (IOException e) {
e.printStackTrace();
}
System.out.print(obj);
}
输出应该是这样的:
{
"name": "MARK ZUCKERBERG",
"srn": "000000001",
"ecc": {
"a": -2,
"b": 13,
"k": 103,
"order": 109
}
}
答案 0 :(得分:0)
试试这个:
function do_header_wp_loaded() {
add_action( 'mytheme_header', 'mytheme_do_header', get_theme_mod( 'mytheme_header_position', '1' ) );
add_action( 'mytheme_header', 'mytheme_do_nav_primary', get_theme_mod( 'mytheme_nav_primary_position', '2' ) );
add_action( 'mytheme_header', 'mytheme_do_nav_secondary', get_theme_mod( 'mytheme_nav_secondary_position', '3' ) );
}
add_action( 'wp_loaded', 'do_header_wp_loaded' );