Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/JSON/EGL/json-1.egl
Normal file
15
Task/JSON/EGL/json-1.egl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
record familyMember
|
||||
person person;
|
||||
relationships relationship[]?;
|
||||
end
|
||||
|
||||
record person
|
||||
firstName string;
|
||||
lastName string;
|
||||
age int;
|
||||
end
|
||||
|
||||
record relationship
|
||||
relationshipType string;
|
||||
id int;
|
||||
end
|
||||
22
Task/JSON/EGL/json-2.egl
Normal file
22
Task/JSON/EGL/json-2.egl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
people Person[]; // Array of people
|
||||
|
||||
people.appendElement(new Person { firstName = "Frederick", lastName = "Flintstone", age = 35} );
|
||||
people.appendElement(new Person { firstName = "Wilma", lastName = "Flintstone", age = 34} );
|
||||
people.appendElement(new Person { firstName = "Pebbles", lastName = "Flintstone", age = 2} );
|
||||
people.appendElement(new Person { firstName = "Bernard", lastName = "Rubble", age = 32} );
|
||||
people.appendElement(new Person { firstName = "Elizabeth", lastName = "Rubble", age = 29} );
|
||||
people.appendElement(new Person { firstName = "Bam Bam", lastName = "Rubble", age = 2} );
|
||||
|
||||
family Dictionary; // A dictionary of family members using a uid as key
|
||||
family["1"] = new FamilyMember{ person = people[1], relationships = [new Relationship{ relationshipType="spouse", id = 2 }, new Relationship{ relationshipType="child", id = 3}] };
|
||||
family["2"] = new FamilyMember{ person = people[2], relationships = [new Relationship{ relationshipType="spouse", id = 1 }, new Relationship{ relationshipType="child", id = 3}] };
|
||||
family["3"] = new FamilyMember{ person = people[3], relationships = [new Relationship{ relationshipType="mother", id = 2 }, new Relationship{ relationshipType="father", id = 1}] };
|
||||
family["4"] = new FamilyMember{ person = people[4], relationships = [new Relationship{ relationshipType="spouse", id = 5 }, new Relationship{ relationshipType="child", id = 6}] };
|
||||
family["5"] = new FamilyMember{ person = people[5], relationships = [new Relationship{ relationshipType="spouse", id = 4 }, new Relationship{ relationshipType="child", id = 6}] };
|
||||
family["6"] = new FamilyMember{ person = people[6], relationships = [new Relationship{ relationshipType="mother", id = 5 }, new Relationship{ relationshipType="father", id = 4}] };
|
||||
|
||||
// Convert dictionary of family members to JSON string
|
||||
jsonString string = jsonLib.convertToJSON(family);
|
||||
|
||||
// Show JSON string
|
||||
SysLib.writeStdout(jsonString);
|
||||
25
Task/JSON/EGL/json-3.egl
Normal file
25
Task/JSON/EGL/json-3.egl
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Convert JSON string into dictionary of family members
|
||||
family Dictionary;
|
||||
jsonLib.convertFromJSON(jsonString, family);
|
||||
|
||||
// List family members and their relationships
|
||||
familyMember FamilyMember;
|
||||
relation FamilyMember;
|
||||
|
||||
keys string[] = family.getKeys();
|
||||
for(i int from 1 to keys.getSize())
|
||||
|
||||
SysLib.writeStdout("----------------------------------------------------");
|
||||
|
||||
familyMember = family[keys[i]];
|
||||
|
||||
SysLib.writeStdout(familyMember.person.lastName + ", " + familyMember.person.firstName + " - " + familyMember.person.age);
|
||||
|
||||
for(j int from 1 to familyMember.relationships.getSize())
|
||||
id string = familyMember.relationships[j].id;
|
||||
relation = family[id];
|
||||
SysLib.writeStdout(familyMember.relationships[j].relationshipType + ": " +
|
||||
relation.person.lastName + ", " + relation.person.firstName);
|
||||
end
|
||||
|
||||
end
|
||||
15
Task/JSON/EGL/json-4.egl
Normal file
15
Task/JSON/EGL/json-4.egl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Service function definition
|
||||
function geocode(address String) returns (GoogleGeocoding) {
|
||||
@Resource{uri = "binding:GoogleGeocodingBinding"},
|
||||
@Rest{method = _GET, uriTemplate = "/json?address={address}&sensor=false",
|
||||
requestFormat = None, responseFormat = JSON}
|
||||
}
|
||||
|
||||
// Invoke service function
|
||||
call geocode("111 Maple Street, Somewhere, CO") returning to callback;
|
||||
|
||||
function callBack(result GoogleGeocoding in)
|
||||
SysLib.writeStdout(result.status);
|
||||
SysLib.writeStdout(result.results[1].geometry.location.lat);
|
||||
SysLib.writeStdout(result.results[1].geometry.location.lng);
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue