我有一个JSON文件,内容如下:
[
{
"Name": "A+",
"Type": "Array",
"Designed by": "Arthur Whitney"
},
{
"Name": "Ada",
"Type": "Compiled, Imperative, Procedural, Object-oriented class-based",
"Designed by": "Tucker Taft, Jean Ichbiah"
}
{
"Name": "C",
"Type": "Compiled, Curly-bracket, Imperative, Procedural",
"Designed by": "Dennis Ritchie"
},
{
"Name": "C#",
"Type": "Compiled, Curly-bracket, Iterative, Object-oriented class-based, Reflective, Procedural",
"Designed by": "Microsoft"
},
{
"Name": "Java",
"Type": "Compiled, Curly-bracket, Imperative, Object-oriented class-based, Procedural, Reflective",
"Designed by": "James Gosling, Sun Microsystems"
},
{
"Name": "JavaScript",
"Type": "Curly-bracket, Interpreted, Reflective, Procedural, Scripting, Interactive mode",
"Designed by": "Brendan Eich"
}
]
我想编写一个Web应用程序,用户输入一个单词FOR EXAMPLE" java"在文本框中,然后单击搜索按钮。在此JSON文件中搜索并在网页中显示结果。 我是网络应用程序的新手。我不知道如何搜索JSON文件并代表结果。任何人都可以帮助我吗?
答案 0 :(得分:0)
如果您只想完成工作,可以使用lodash而不是简单地执行以下操作:
var data = [...] // your jsonfile as array of objects
_.findWhere(data, {Name:"Java"}) // returns the object