Map<String, HashSet<String>> to JSON, & Pretty Print - json

I'm trying to make my dataset correspond to this example:
var family = [{
"name" : "Jason",
"age" : "24",
"gender" : "male"
},
{
"name" : "Kyle",
"age" : "21",
"gender" : "male"
}];
I have a Map<String, HashSet<String>> of Names and unique alpha-numeric values correponding to specific entities to which those names could refer, let's call these entry items "IDs".
So for instance, Fyodor Mikhailovich Dostoyevsky would perhaps be related to the ID Q626, because that's a very specific reference, there aren't many widely known figures with that name. Whereas, Bush might be attached to G027, Q290, and Q118, referencing perhaps the man, the beer, and the shrub, in no particular order.
It looks like this (the real one is much bigger):
[Rao=[Q7293658, , Q7293657, Q12953055, Q3531237, Q4178159, Q1138810, Q579515, Q3365064, Q7293664, Q1133815], Hani Durzy=[], Louise=[, Q1660645, Q130413, Q3215140, Q152779, Q233203, Q7871343, Q232402, Q82547, Q286488, Q156723, Q3263649, Q456386, Q233192, Q14714149, Q12125864, Q57669, Q168667, Q141410, Q166028], Reyna=[Q7573462, Q2892895, Q363257, Q151944, Q3740321, Q2857439, Q1453358, Q7319529, Q733716, Q16151941, Q7159448, Q5484172, Q6074271, Q1753185, Q7319532, Q5171205, Q3183869, Q1818527, Q251862, Q3840414, Q5271282, Q5606181]]
Using Jackson I tried like this:
Map<String, HashSet<String>> map = q_valMap;
mapper.writeValue(new File("JSON_Output/user.json"), map);
But this seems wrong, as my output was all jumbled together, i.e.
{"Rao":["Q7293658","","Q7293657","Q12953055","Q3531237","Q4178159","Q1138810","Q579515","Q3365064","Q7293664","Q1133815"],"Hani Durzy":[""],"Louise":["","Q1660645","Q130413","Q3215140","Q152779","Q233203","Q7871343","Q232402","Q82547","Q286488","Q156723","Q3263649","Q456386","Q233192","Q14714149","Q12125864","Q57669","Q168667","Q141410","Q166028"],"Reyna":["Q7573462","Q2892895","Q363257","Q151944","Q3740321","Q2857439","Q1453358","Q7319529","Q733716","Q16151941","Q7159448","Q5484172","Q6074271","Q1753185","Q7319532","Q5171205","Q3183869","Q1818527","Q251862","Q3840414","Q5271282","Q5606181"]}
Do I just have to populate this JSON object iteratively?
Like the example up top, I think it should look something like this, though what follows is only a pseudocodish characterization, which is to say, not exactly this but something similar:
{
key: "Rao"
value: ["Q7293658","","Q7293657","Q12953055","Q3531237","Q4178159","Q1138810","Q579515","Q3365064","Q7293664","Q1133815"]
key: "Hani Durzy"
value: [""]
key: "Louise"
value: ["","Q1660645","Q130413","Q3215140","Q152779","Q233203","Q7871343","Q232402","Q82547","Q286488","Q156723","Q3263649","Q456386","Q233192","Q14714149","Q12125864","Q57669","Q168667","Q141410","Q166028"]
key: "Reyna"
value: ["Q7573462","Q2892895","Q363257","Q151944","Q3740321","Q2857439","Q1453358","Q7319529","Q733716","Q16151941","Q7159448","Q5484172","Q6074271","Q1753185","Q7319532","Q5171205","Q3183869","Q1818527","Q251862","Q3840414","Q5271282","Q5606181"]
}
is that not right?
UPDATE
public class JsonMapFileExample
{
public static void map(Map<String, HashSet<String>> q_valMap )
{
ObjectMapper mapper = new ObjectMapper();
ArrayNode array = mapper.createArrayNode();
for ( Entry entry: q_valMap.entrySet() )
{
ObjectNode node = mapper.createObjectNode()
.put("name", entry.getKey())
.put("ids", entry.getValue());
array.add(node);
}
mapper.writeValue("/home/matthias/Workbench/SUTD/nytimes_corpus/wdtk-parent/wdtk-examples/JSON_Output/user.json", array);
}
}
class MyEntity
{
private String name;
Set<String> value; // use names that you want in the result JSON
//constructors
public MyEntity()
{
}
public MyEntity(String name)
{
this.name = name;
}
//getters
public String getName()
{
return this.name;
}
public Set<String> getValue()
{
return this.value;
}
//setters
public void setName(String name)
{
this.name = name;
}
public void setValue(Set<String> value)
{
this.value = value;
}
}

You could manually set the key names, something like:
ArrayNode array = mapper.createArrayNode();
for (Entry entry: yourMap.entries()) {
ObjectNode node = mapper.createObjectNode()
.put("name", entry.key())
.putPOJO("ids", entry.value());
array.add(node);
}
mapper.writeValue(file, array);
Alternatively, you could create a class for your data
class MyEntity {
String name;
Set<String> ids; // use names that you want in the JSON result
// getters, setters if necessary
}
Transform your data map into a list of MyEntity, then use Jackson ObjectMapper to create JSON like mapper.writeValue(file, listOfMyEntities), the output would be like
[
{
"name": "some name here",
"ids": ["id1", "id2", ...]
}
// more elements here
]

how about this:
String name_list_file = "/home/matthias/Workbench/SUTD/nytimes_corpus/NYTimesCorpus/2005/01/02/test/people_test.txt";
String single_name;
try (
// read in the original file, list of names, w/e
InputStream stream_for_name_list_file = new FileInputStream( name_list_file );
InputStreamReader stream_reader = new InputStreamReader( stream_for_name_list_file , Charset.forName("UTF-8"));
BufferedReader line_reader = new BufferedReader( stream_reader );
)
{
while (( single_name = line_reader.readLine() ) != null)
{
//replace this by a URL encoder
//String associated_alias = single_name.replace(' ', '+');
String associated_alias = URLEncoder.encode( single_name , "UTF-8");
String platonic_key = single_name;
System.out.println("now processing: " + platonic_key);
Wikidata_Q_Reader.getQ( platonic_key, associated_alias );
}
}
//print the struc
Wikidata_Q_Reader.print_data();
}

Related

How to check the input string present in json array using json path

I am trying to check the given input string is present in a json array. Below is my sample json
{
"school": {
"class": {
"standard": "6",
"student_list": [
"Daniel",
"Jack",
"John"
]
}
}
}
Let say i am trying to find a given input name is part of student_list if the given input name matches then it should retrieve the complete details of the class. Let say i am passing name 'John' it should give me below result
{
"standard": "6",
"student_list": [
"daniel",
"jack",
"john"
]
}
I am using jayway json path library i tried couple of ways like below
$.school.class.[?('john' anyof #.student_list)]
$.school.class.[?(#.'john' anyof #.student_list)]
But every time it is giving me empty array. I am new to jsonpath query could you please point me where i am going wrong or help me what is wrong with my json path query.
The comparison is case sensitive.
Filter Operator anyof -- left has an intersection with right [?(#.sizes anyof ['M', 'L'])]
Indefinite paths always returns a list
Change your query to
$.school.class[?(#.student_list anyof ['John'])]
OR
$.school.class[?(#.student_list contains 'John')]
OR
$.school.class[?('John' in #.student_list)]
Here click for git repo is the code to check JSON object is present in whole JSON object:
private static Map<String, Object> getJsonMapFlatten(String json) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
MapType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, Object.class);
Map<String, Object> map = mapper.readValue(json, type);
return JsonMapFlattener.flatten(map);
}
public static void getJsonValue(String json, String keyName) throws JsonProcessingException {
Map<String, Object> map = getJsonMapFlatten(json);
Iterator<Map.Entry<String, Object>> itr = map.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<String, Object> obj = itr.next();
if (obj.getKey().contains(keyName)) {
System.out.println(obj.getKey() + "==>" + obj.getValue());
}
}
}
public static void validateJson(String json, String jsonToCompare) throws JsonProcessingException {
Map<String, Object> flattenJsonResponse = getJsonMapFlatten(json);
Map<String, Object> flattenResponseToCompare = getJsonMapFlatten(jsonToCompare);
List<String> jsonResponsePaths = getJsonPaths(flattenJsonResponse);
List<String> responsePathsToCompare = getJsonPaths(flattenResponseToCompare);
if (flattenJsonResponse.size() >= flattenResponseToCompare.size()) {
for (String jsonPath : responsePathsToCompare) {
if (isPathPresent(jsonResponsePaths, jsonPath)) {
System.out.println("path present: " + jsonPath);
System.out.println(getPath(jsonResponsePaths, jsonPath));
System.out.println(flattenResponseToCompare.get(jsonPath) + "<==>" + flattenJsonResponse.get(getPath(jsonResponsePaths, jsonPath)));//store the values
} else {
System.out.println("path is not present: " + jsonPath);
}
}
} else {
for (String jsonPath : jsonResponsePaths) {
if (isPathPresent(responsePathsToCompare, jsonPath)) {
System.out.println(flattenJsonResponse.get(jsonPath) + "==" + flattenResponseToCompare.get(getPath(responsePathsToCompare, jsonPath)));
} else {
System.out.println("path is not present: " + jsonPath);
}
}
}
}
private static List<String> getJsonPaths(Map<String, Object> map) {
List<String> list = new ArrayList<>();
Iterator<String> itr = map.keySet().iterator();
while (itr.hasNext()) {
list.add(itr.next());
}
return list;
}
private static boolean isPathPresent(List<String> paths, String path) {
for (String list : paths) {
if (list.contains(path)) {
return true;
}
}
return false;
}
private static String getPath(List<String> paths, String path) {
for (String list : paths) {
if (list.contains(path)) {
return list;
}
}
throw new NullPointerException("No such path exist " + path);
}

.NET 6 - Change Json Property Casing

How can I change the casing of the property names of a json without performing model binding?
JsonElement serialization ignores PropertyNaming JsonSerializer options as is also confirmed here: https://github.com/dotnet/runtime/issues/61843
The suggested use of JsonNode/JsonObject results in the same behavior.
Any hints how I can accomplish this?
As example I want to change this:
{
"MyPoperty" : 5,
"MyComplexProperty" : {
"MyOtherProperty": "value",
"MyThirdProperty": true
}
}
to this:
{
"myPoperty" : 5,
"myComplexProperty" : {
"myOtherProperty": "value",
"myThirdProperty": true
}
}
Cheers.
I think you try to use Newtonsoft json
class Person
{
public string UserName { get; set; }
public int Age { get; set; }
}
coding
static void Main(string[] args)
{
Person person = new Person();
person.UserName = "Bob";
person.Age = 20;
var serializerSettings = new JsonSerializerSettings();
serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
var json = JsonConvert.SerializeObject(person, serializerSettings);
Console.WriteLine(json);
}
output
{"userName":"Bob","age":20}
not depend on Newtonsoft json but in the case of multi-layer objects
var json = #"{""ShouldWindUpAsCamelCase"":""does it?""}";
var obj = JsonSerializer.Deserialize<Dictionary<string,string>>(json);
var dic = new Dictionary<string, string>();
foreach (var item in obj)
{
dic.Add(item.Key.FirstCharToLower(), item.Value);
}
var serialized = System.Text.Json.JsonSerializer.Serialize(dic);
Console.WriteLine(serialized);
FirstCharToLower() function
public static string FirstCharToLower(this string input)
{
if (String.IsNullOrEmpty(input))
return input;
string str = input.First().ToString().ToLower() + input.Substring(1);
return str;
}
#output
{"shouldWindUpAsCamelCase":"does it?"}

Render complex object in JSON in grails

I have complex object and I want to render it, but I have several problems in view.
First of all, I have UUID field in my class but in View I get not the String but mostSigBits and leastSigBits.
The second one, I have my enums fields like two fields with enum and value
For example,
public class ExampleObject {
#JsonProperty("id")
private UUID id;
#JsonProperty("name")
private String name;
#JsonProperty("address")
private String address;
#JsonProperty("port")
private String port;
#JsonProperty("users")
#Valid
private List<UserRef> users = null;
#JsonProperty("indexingParameters")
private IndexingParameters indexingParameters;
#JsonProperty("otherParameters")
private OtherParameters otherParameters;
#JsonProperty("status")
private Status status;
}
When I get response from controller I get answer with this one
{
"id": {
"leastSignificantBits": -5406850341911646206,
"mostSignificantBits": 8884977146336383467
},
"status": {
"enumType": "api.model.Status",
"name": "GENERAL"
}
....
}
The problem is I have a lot of different but with the same problem objects in my code. If there is only 1 object, I`d easy prepare some _exampleObject.gson template and render every answer from controller to it, but I have many objects.
I think there are some variants to render correct my JSON, isn`t there?
Another rendering variants where data is ExampleObject.class or something like that
1)code:
Map map = [content: data.content, sorting: data.sorting, paging: data.paging] as Map
render AppResponse.success([success: true, data: map]).asJSON()
render data as JSON
on front:
Incorrect UUID and DateTime convert each field in Object, But I need Timeshtamp
"id": {"leastSignificantBits": -5005002633583312101,
"mostSignificantBits": 4056748206401340307},
"key": "b48d35dd-0551-4265-a1b1-65105e713811",
2)code:
Map map = [data: new ObjectMapper().writeValueAsString(data)] as Map
render map
on front:
Here we can see square brackets at the start which is wrong for JSON
['data':'{"content":[{"id":"384c7700-09c1-4393-ba8a-a89f555f431b","name":"somename"...
3)code:
Object result = new HashMap<String, Object>()
result.success = true
result["data1"] = new ObjectMapper().writeValueAsString(data)
render result as JSON
on front:
Here we can see quotes escaping
"data": "{\"content\":[{\"id\":\"384c7700-09c1-4393-ba8a-a89f555f431b\",\"name\":\"somename\",\"key\":\"b48d35dd-0551-4265-a1b1-65105e713811\",\"status\":\"COMPLETED\.......
I did it like this
#CompileStatic
class MyProxyController {
#Autowired
Myservice service
static ObjectMapper objectMapper = new ObjectMapper()
.registerModule(new JodaModule())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
def getExampleObject {
ExampleObject exampleObject = service.getExampleObject()
render([contentType: "application/json"], objectMapper.writeValueAsString(new CustomObject(data, true)))
}
#CompileStatic
class CustomObject {
Boolean success
Object data
CustomObject(Object data, Boolean success) {
this.data = data
this.success = success
}
}
}
And get json as I wanted like
{
"success": true,
"data": {
"content": [
{ ....

Array retrieval from JSON file

I have an array in JSON file which look like this
{ "fields": [
{
"name": "order_id",
"type": "INTEGER",
"position": 0
},
{
"name": "district_id",
"type": "INTEGER",
"position": 1
}]
}
I'm using a TREE MODEL in retrieving the contents of the array "fields" and my code looks like this ..
public static void main(String[] args) throws JsonParseException, IOException {
File jsonFile = new File("metadata.json");
String theJsonString = jsonFile.toString();
String name = null;
String type =null;
int position = 0;
ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
JsonNode rootNode = mapper.readTree(theJsonString);
JsonNode fields = rootNode.get("fields");
if (fields != null) {
for (int i = 0; i < fields.size(); i ++) {
if(fields.has("name"))
name = fields.get("name").getTextValue();
if(fields.has("type"))
type = fields.get("type").getTextValue();
if(fields.has("position"))
position = fields.get("position").getIntValue();
System.out.println(name);
}
}
}
I get the following error during the run time ::
Exception in thread "main" org.codehaus.jackson.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
at [Source: java.io.StringReader#3eed2cab; line: 1, column: 2]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:385)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:306)
at org.codehaus.jackson.impl.ReaderBasedParser._skipComment(ReaderBasedParser.java:1498)
at org.codehaus.jackson.impl.ReaderBasedParser._skipWSOrEnd(ReaderBasedParser.java:1474)
at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:362)
at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2761)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709)
at org.codehaus.jackson.map.ObjectMapper.readTree(ObjectMapper.java:1533)
at metadata.JSONParser.main(JSONParser.java:32)
I have just started working with JSON and hence unable to find a solution. Could anybody help me resolve this?
If you want the contents of the file metadata.json then calling toString on the file will not give you that. Instead it will give you a string which holds the path to the filename.
Instead create a FileInputStream from the File like so:
FileInputStream fis = new FileInputStream(jsonFile);
The you can use it with the mapper
JsonNode rootNode = mapper.readTree(fis);
You might also want to call fields.get(i) when you are iterating through the array to access each JsonNode contained in the array.
I have the same problem and I fixed the problem finally by this code to get the JsonParser object.
FileInputStream fis = new FileInputStream(path);
JsonParser jp = new JsonFactory().createParser(fis);
I had the same problem few days ago. My JSON have the next syntax:
{ "boxes": [
{
"name": "redBox.png",
"version": 15
},
{
"name": "blueBox.png",
"version": 9
}
]
}
I had to create method which return me POJO classes with box versions. My solution is follow:
private static List<DataVersion> receiveDataVersions() throws IOException
{
String path = System.getProperty( "user.dir" ) + File.separator +
"versions.json";
List<DataVersion> versions = new ArrayList<>();
JsonNode folder = null;
try( InputStream stream = new FileInputStream( path ) )
{
folder = new ObjectMapper().readTree( stream );
}
JsonNode boxes = folder.get( "inst" );
boxes.forEach( version -> versions.add( new DataVersion(
version.get( "name" ).getTextValue(),
version.get( "version" ).getIntValue() ) ) );
return versions;
}
POJO is as follows:
public class DataVersion
{
private String name;
private int version;
public DataVersion() {
}
public DataVersion(String name, int version) {
this.name = name;
this.version = version;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getVersion() {
return version;
}
public void setVersion(int version){
this.version=version;
}
#Override
public String toString()
{
return "DataVersion [" + "name='" + name + '\'' + ", version=" +
version + ']';
}
}
try this in your code
jsonFactory.enable(JsonParser.Feature.ALLOW_COMMENTS);

Resolving Nested JSON issue using Spring-Hibernate

I am using spring mvc and jackson for my extjs application and stuck at some thing similar.
I have my list of records returned from DB using Hibernate.
DAO class:
#SuppressWarnings("unchecked")
#Override
public List<CandidateStatus> getcandidateStatus() {
//return hibernateTemplate.find("select candstat.candidate.firstName as firstName,candstat.candidate.lastName as lastName,candstat.candidate.email as email,candstat.statusTitle as statusTitle,candstat.requirement.client.clientName as clientName,candstat.requirement.reqTitle as reqTitle from CandidateStatus as candstat");
return hibernateTemplate.find("from CandidateStatus");
//return hibernateTemplate.find("from CandidateStatus candstat left outer join candstat.candidate left outer join candstat.requirement left outer join candstat.requirement.client");
//return hibernateTemplate.find("from Candidates as cands inner join cands.candidateStats");
}
**Service class**
public List<CandidateStatus> getCandidateStatusList()
{
//return candidatesDAO.getCandidates();
return candidatesDAO.getcandidateStatus();
}
Controller class
#RequestMapping(value="/candidates/view.action")
public #ResponseBody Map<String,? extends Object> view() throws Exception {
try{
//List<Candidates> candidates = candidatesService.getCandidatesList();
List<CandidateStatus> candidatestatus = candidatesService.getCandidateStatusList();
return getMap(candidatestatus);
} catch (Exception e) {
return getModelMapError("Error retrieving Candidates from database.");
}
private Map<String,Object> getMap(List<CandidateStatus> candidatestatus){
Map<String,Object> modelMap = new HashMap<String,Object>(3);
modelMap.put("success", true);
modelMap.put("total", candidatestatus.size());
modelMap.put("data", candidatestatus);
return modelMap;
}
private Map<String,Object> getModelMapError(String msg){
Map<String,Object> modelMap = new HashMap<String,Object>(2);
modelMap.put("message", msg);
modelMap.put("success", false);
return modelMap;
}
Before adding it to the map I want to format the JSON in a required format as per my application.I get the format in a nested manner which is not accepted by extjs.
{
"data": [
{
"id": 29,
"requirement": {
"id": 27,
"client": {
"id": 12,
"clientName": "HireCraft"
},
"clientId": 12,
"reqTitle": "Support Engineer"
},
"reqid": 27,
"resid": 45,
"candidate": {
"id": 45,
"firstName": "Vikram",
"lastName": "",
"email": "bj.vikram#gmail.com"
},
"statusTitle": "Shortlisted"
}],
"success":true,
"total":7668
}
I want the json to be flat file like this without nesting.
"data": [ {
"clientName": "ABC"
"firstName": "Suynil",
"lastName": "Seelam",
"email": "ss.seelam#gmail.com",
"reqTitle": "Java"}]success:true,total:768}
Can you please guide me how I can achive this.I have stuglling for long over this issue!
I tried a bit and getting something likethis.
private Map<String,Object> getMap(List<CandidateStatus> candidatestatus){
Map<String,Object> modelMap = new HashMap<String,Object>(3);
Map<String,Object> candDetails = new HashMap<String,Object>(7);
Iterator<CandidateStatus> iterator=candidatestatus.iterator();
CandidateStatus astring = new CandidateStatus();
String Client;
String Fname;
String Lname;
String Email;
String Phone;
String Status;
String Require;
while(iterator.hasNext())
{
astring = iterator.next();
/*System.out.println(astring.getCandidate().getFirstName());
System.out.println(astring.getCandidate().getLastName());
System.out.println(astring.getCandidate().getEmail());
System.out.println(astring.getStatusTitle());
System.out.println(astring.getRequirement().getReqTitle());*/
Client = astring.getRequirement().getClient().getClientName();
Fname = astring.getCandidate().getFirstName();
Lname = astring.getCandidate().getLastName();
Email = astring.getCandidate().getEmail();
Phone = astring.getCandidate().getPhone();
Status = astring.getStatusTitle();
Require= astring.getRequirement().getReqTitle();
candDetails.put("clientName",Client);
candDetails.put("firstName",Fname);
candDetails.put("lastName",Lname);
candDetails.put("email",Email);
candDetails.put("phone",Phone);
candDetails.put("statusTitle",Status);
candDetails.put("reqTitle",Require);
//jsonMap.put("root", candDetails);
//System.out.println(jsonMap);
}
//System.out.println("----"+candDetails+"----");
modelMap.put("success", true);
modelMap.put("total",candDetails.size());
modelMap.put("data",candDetails );
return modelMap;
Now when I try to add candDetails to the modelMap I get only the LAST record.Why???
Thanks
I don't think your second example is valid JSON, at least according to json.org. An object is defined as:
an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
That tells me that JSON has to start with a '{' and end with a '}'.
Your approach will work, if you change you work with map candDetails witch is kinda silly. In your loop you put data with same key, thats why you get data with last iterate.
I suggest you to write custom wrapper object(lets call it CandidateStatusWrapper and build there all structure you need. Then you just return list of wrapped objects.
Wrapper example:
class CandidateStatusWrapper {
String clientName;
String firstName;
public CandidateStatusWrapper(String clientName, String firstName) {
this.clientName = clientName;
this.firstName = firstName;
}
}
Change your map:
Map<String,Object> candDetails = new HashMap<String,Object>(7);
into list:
List<CandidateStatusWrapper> = new ArrayList<CandidateStatusWrapper >();
Loop in Controller:
while(iterator.hasNext())
{
astring = iterator.next();
Client = astring.getRequirement().getClient().getClientName();
Fname = astring.getCandidate().getFirstName();
CandidateStatusWrapper wrapped = new CandidateStatusWrapper(Client, Fname);
candDetails.add(wrapped);
}