-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyBatch.cls
More file actions
32 lines (28 loc) · 1.28 KB
/
MyBatch.cls
File metadata and controls
32 lines (28 loc) · 1.28 KB
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
public with sharing class MyBatch {
public MyBatch() {}
public void runBatch() {
// this is the json string that will be parsed by the json mapper.
// in our situation, this resides in a content note.
String jsonString = '{' +
'"frameHeight" : "32",' +
'"frameWidth" : "2",' +
'"wheelOneRadius" : "27",' +
'"wheelOneReflectorOneColor" : "red",' +
'"wheelOneReflectorOneWidth" : "3",' +
'"wheelOneReflectorTwoColor" : "white",' +
'"wheelOneReflectorTwoWidth" : "4",' +
'"wheelTwoRadius" : "27",' +
'"wheelTwoReflectorOneColor" : "white",' +
'"wheelTwoReflectorOneWidth" : "4",' +
'"wheelTwoReflectorTwoColor" : "blue",' +
'"wheelTwoReflectorTwoWidth" : "1"' +
'}';
// call the json mapper to parse the json into an apex object.
JsonToBikeMapper jsonMapper = new JsonToBikeMapper();
Bicycle bikeFromJson = jsonMapper.parseJson(jsonString);
// now that we've got an apex object, we'll call the mapper that
// knows the database schema.
BikeMapper myBikeMapper = new BikeMapper();
Bicycle savedBike = myBikeMapper.saveBike(bikeFromJson);
}
}