Hi Team,
I have used invoke method to add get the JSON array. how to check if there are duplicate keys in this jsonarray. I am unable to check for the duplicates in it.
Please help me to resolve this issue
Hi Team,
I have used invoke method to add get the JSON array. how to check if there are duplicate keys in this jsonarray. I am unable to check for the duplicates in it.
Please help me to resolve this issue
I’m facing a similar issue too! A sample json array would be:
{
admin: false,
default:true,
admin:true
}
The above array has duplicate admin keys.I need to throw an error when the user enters duplicate keys.
Hi @Harshini_Lakshmi ,
Welcome to the Community.
@ppr , @Robinnavinraj_S , @90s_Developer, @THIRU_NANI can also help you here.
Thanks !
Hi @Harshini_Lakshmi ,
My suggestion for your question is try converting your json array to datatable by using the deserialize Json Array so that once you get the json array in datatable format you will be able to find out whether the key is having duplicates or not. thanks.
Hi @Harshini_Lakshmi ,
From the solution @kirankumar.mahanthi1 provided you can convert your Json into a datatable
1.Deserialize the Array
2.Assign a datatable to JsonConvert.DeserializeObject(of DataTable)(YourJArray.ToString)
3. Then post that check for duplicacy.
Thanks
Oh okay, I’ll do that. Thank you @Shikhar_Tandon @kirankumar.mahanthi1
@Harshini_Lakshmi
may we ask you to open a new topic on this., Your case is about duplicated Properties related to the property name. This Topic is about duplicated items within an JSON array
A handling via datatable conversion we would not recommend.
Serialized JSON had following result
So working on text level could be a better option