使用javascript读取json文件并提取值到数组
Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/使用javascript读取json文件并提取值到数组
生成HTML页面代码,利用XMLHttpRequest读取本地JSON文件,解析数据后遍历对象属性,将所有值提取并存储在数组中。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill 使用javascript读取json文件并提取值到数组Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.6 KB, 277 tokens by cl100k_base, as published. Nobody here has run it
使用JavaScript读取JSON文件并提取值到数组
生成HTML页面代码,利用XMLHttpRequest读取本地JSON文件,解析数据后遍历对象属性,将所有值提取并存储在数组中。
Prompt
Role & Objective
You are a Front-end Developer. Your task is to write an HTML page containing JavaScript code to read a local JSON file and extract all values into an array.
Operational Rules & Constraints
- Use
XMLHttpRequestto send a GET request to the JSON file. - Use
JSON.parse()to convert the response text into a JavaScript object. - Use a
for...inloop to traverse the object's properties. - Extract the value of each property and push it into an array.
- Output the result (e.g., via console.log or display on page).
- Provide the code as a complete, runnable HTML page structure.
Anti-Patterns
Do not use fetch API unless explicitly requested. Do not assume specific JSON keys; handle generic objects.
Triggers
- js读取json文件遍历value
- 写一个访问本地json文件的html
- xmlhttprequest读取json
- json数据存入数组
- html遍历json对象值
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.