Key Facts
- Category
- Data Processing
- Input Types
- textarea, text
- Output Type
- text
- Sample Coverage
- 4
- API Ready
- Yes
Overview
This tool removes duplicate entries from a pre-sorted array by comparing values at a specified property path, using the lodash _.sortedUniqBy function to return a unique JSON array.
When to Use
- •When you have a sorted list of objects and need to eliminate duplicates based on a specific key or nested property.
- •To clean up data from APIs, databases, or exports where duplicates might occur in sorted order without re-sorting.
- •When preparing data for further processing, analysis, or display, ensuring uniqueness while maintaining the original sort sequence.
How It Works
- •Input a JSON array that is already sorted in ascending order.
- •Specify the property path to compare for duplicates, such as 'id' or 'meta.key'.
- •The tool applies lodash's _.sortedUniqBy to remove consecutive duplicate entries based on the path.
- •Output the resulting unique array as JSON, preserving the sort order.
Use Cases
Examples
1. Deduplicate User Records
Data Analyst- Background
- You have a sorted JSON array of user objects exported from a CRM system, sorted by registration date.
- Problem
- Duplicate user entries exist with the same 'userId' field, skewing analytics.
- How to Use
- Paste the sorted array into the Array field and set the Property Path to 'userId'.
- Outcome
- A JSON array with unique user objects, ready for accurate analysis without duplicates.
2. Clean Sorted Product Inventory
- Background
- An e-commerce platform provides a product list sorted by SKU, but some entries are duplicated.
- Problem
- Duplicate SKUs need removal to ensure inventory counts are correct.
- How to Use
- Input the sorted product array and specify 'sku' as the property path.
- Outcome
- A unique product list in JSON format, maintaining sort order for inventory management.
Try with Samples
json, videoRelated Hubs
FAQ
What input format is required?
A JSON array that must be sorted before use.
Can I use nested property paths?
Yes, paths like 'meta.key' are supported for comparing nested values.
What if the array is not sorted?
The tool assumes sorted input; unsorted arrays may not produce correct results.
Is the output in JSON format?
Yes, the result is a JSON array of unique objects.
Do I need to install lodash?
No, the tool uses lodash internally; you only provide the input array and path.