Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
62 lines (53 loc) · 2.33 KB

File metadata and controls

62 lines (53 loc) · 2.33 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
// Spaces in JSON strings are needed to ensure json cache kicks in
// An example of showing path type divergence a->b, a->b, a->b, a->c, a->b
function test1()
{
var jsonString = " [ {\"a\":1, \"b\":2}, {\"a\":1, \"b\":2}, {\"a\":1, \"b\":2}, {\"a\":1, \"c\":2}, {\"a\":1, \"b\":2} ]"
var json = JSON.parse(jsonString);
TraverseJSONObject("Path type divergence" , 1, json, true);
}
// An example of showing numerical property a->b->1->c, a->b->1->c
function test2()
{
var jsonString = " [ {\"a\":1, \"b\":2, \"1\":3, \"c\":4 }, {\"a\":1, \"b\":2, \"1\":3, \"c\":4 }, {\"a\":1, \"b\":2, \"1\":3, \"c\":4 }, {\"a\":1, \"b\":2, \"1\":3, \"c\":4 }] "
var json = JSON.parse(jsonString);
TraverseJSONObject("Numerical properties" , 1, json, true);
}
// Tests having duplicate property names
function test3()
{
var jsonString = " [ {\"a\":1, \"b\":2, \"c\":3, \"d\":4,\"a\":5, \"a\":6, \"b\":7 }, {\"a\":1, \"b\":2, \"c\":3, \"d\":4,\"a\":5, \"a\":6, \"b\":7 }, {\"a\":1, \"b\":2, \"c\":3, \"d\":4,\"a\":5, \"a\":6, \"b\":7 }, {\"a\":1, \"b\":2, \"c\":3, \"d\":4,\"a\":5, \"a\":6, \"b\":7 }] "
var json = JSON.parse(jsonString);
TraverseJSONObject("Duplicates" , 1, json, true);
}
function TraverseJSONObject(msg, level, o, doRecurse) {
doRecurse = doRecurse || false;
var sp = "";
if(level == 1)
{
WScript.Echo(msg);
}
for(var i=1; i<level; i++) {
sp += " ";
}
for(var l in o) {
WScript.Echo(sp + l + ": " + o[l]);
if (doRecurse) {
TraverseJSONObject(msg, level+1, o[l]);
}
}
}
function RunAll()
{
WScript.Echo("Running test1...");
test1();
WScript.Echo("Running test2...");
test2();
WScript.Echo("Running test3...");
test3();
}
RunAll();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.