0

I have json array ob object list name of array is value in this array i have on inside value object i have another object called filed i want access filed object and find duplicate any help?. Update: i used System.out.println("a : " + Collections.frequency(stringList, "Accounts Receivable")); method but its give me 0 always

{
"",
"value": [
    {
        "@odata.etag": """,
        "createdDateTime": "",
        "eTag": """,
        "id": "",
        "lastModifiedDateTime": "",
        "webUrl": "",
        "createdBy": {
            "user": {
                "email": "",
                "id": "",
                "displayName": ""
            }
        },
        "lastModifiedBy": {
            "user": {
                "email": ",
                "id": "",
                "displayName": ""
            }
        },
        "parentReference": {},
        "contentType": {
            "id": ""
        },
        "fields@odata.context": "",
        "fields": {
            "@odata.etag": """,
            "id": "",
            "ContentType": "",
            "Modified": "",
            "Created": "",
            "AuthorLookupId": "",
            "EditorLookupId": "",
            "_UIVersionString": "",
            "Attachments": false,
            "Edit": "",
            "ItemChildCount": "0",
            "FolderChildCount": "0",
            "_ComplianceFlags": "",
            "_ComplianceTag": "",
            "_ComplianceTagWrittenTime": "",
            "_ComplianceTagUserId": "",
            "JobCategory": "",--> "check this value for duplicate"
            "Competency": "",
            "Level": "",
            "CompetencyType": "",
            "Index": "0",
            "FormID@odata.type": "",
            "FormID": 25
        }
    }]

in side value array list there is fields object but while trying its given only object here is my Code.

   Set<Example> uniqueSet = new HashSet<Example>(borrowModelList);

            for (Example temp : uniqueSet) {


                txtInfo.setText(String.valueOf(Collections.frequency(borrowModelList,temp.getValue().get(0).getFields())));
                textInfoOne.setText(String.valueOf(Collections.frequency(borrowModelList,temp.getValue().get(0).getFields())));
                textInfoTwo.setText(String.valueOf(Collections.frequency(borrowModelList,temp.getValue().get(0).getFields())));
                textInfoThree.setText(String.valueOf(Collections.frequency(borrowModelList,temp.getValue().get(0).getFields())));
                textInfoFour.setText(String.valueOf(Collections.frequency(borrowModelList,temp.getValue().get(0).getFields())));
            }

I/System.out: 1 in side field object there is JobCategory field i want to check only and show on textview.

007
  • 3
  • 2
  • 6
  • You misunderstood the first parameter in [Collections#frequency​(Collection> c, Object o)](https://docs.oracle.com/javase/9/docs/api/java/util/Collections.html#frequency-java.util.Collection-java.lang.Object-). It should be `exampleList.get(0).getFields()`. – Jay Oct 04 '18 at 05:42
  • 1) what is your _number duplicate element_? Is this a field in json or says which object is duplicated or how many duplicates of an object occure? – P.Juni Oct 04 '18 at 05:55
  • i hove 15 object in side value and each value has field object – 007 Oct 04 '18 at 06:01
  • @P.Juni pleas check my edit code i am not able to access filed object inside value array list – 007 Oct 04 '18 at 06:06
  • @P.Juni any Suggestion on this – 007 Oct 04 '18 at 07:00
  • i'm afraid, i can't fully understand how do you want to check if the duplicates occure. Do you want to get some specific field from an object and then check if it occures more than once in the whole json? Is so, what is the field – P.Juni Oct 04 '18 at 07:03
  • i have so many duplicate value inside field object so i want to check duplicate value in field object only. – 007 Oct 04 '18 at 07:11
  • @P.Juni do you want all json data to see? – 007 Oct 04 '18 at 07:12
  • @P.Juni please check my edit code i want to check field object value only and display it. – 007 Oct 04 '18 at 07:19
  • can any one give me suggestion on this. – 007 Oct 04 '18 at 09:01
  • @P.Juni do you have any suggestion? – 007 Oct 04 '18 at 11:11
  • sorry not really :( – P.Juni Oct 04 '18 at 11:11
  • Any body give me any suggestion what here i missed. – 007 Oct 05 '18 at 04:38
  • @007 r u using rest api or soap service, if u r using rest api then in server side code u can restrict the duplicate records, and once see this link https://stackoverflow.com/questions/23507853/remove-duplicate-objects-from-json-array. Thank you – Vijaya Varma Lanke Oct 05 '18 at 04:55
  • @Varma its sharepoint rest api. – 007 Oct 05 '18 at 04:57
  • @Varma no aculty requirment is like that i have to cont number of duplcate value and show into textview. but while using hashmap its not reading inner object i think that is issue. – 007 Oct 05 '18 at 04:58
  • @007 see this link https://javarevisited.blogspot.com/2015/06/3-ways-to-find-duplicate-elements-in-array-java.html, replace // your duplicate element with count variable. thank u – Vijaya Varma Lanke Oct 05 '18 at 05:05
  • @Varma i tryied alradey but its example about simple array i have inner object and control not read that. – 007 Oct 05 '18 at 05:22
  • @007 copy u r json values to individual array and then check y u r struggling this much – Vijaya Varma Lanke Oct 05 '18 at 05:24

0 Answers0