cancel
Showing results for 
Search instead for 
Did you mean: 

Filter and Edit a JSON with a touch of data manipulation

BarryStarck
New Contributor II

Hi,

I need to amend some data for a specific table flowing through one of my pipelines

This specific json contains multiple values for example:

L_TYPE “A”
L_TYPE “A”
L_TYPE “A”
L_TYPE “B”
L_TYPE “B”
L_TYPE “B”
L_TYPE “C”
L_TYPE “C”
L_TYPE “C”
L_TYPE “D”
L_TYPE “D”
L_TYPE “D”

Firstly what I need to do is remove all but ONE of the L_TYPE “C”’s and ALL of the L_TYPE “D” records

Once that has been achieved I need to edit the data within the remaining L_TYPE “C”

L_TYPE “C”
ID: 1
Value: 33
Date: XX XX XX

What I need to do with the single remaining L_TYPE “C” is make the value data match the id data

any help would be very much appreciated

1 REPLY 1

alchemiz
Contributor III

Hi Sir Barry,

Good day, I would suggest to use match for string comparison the return will be an array of string then you can dedups the array to get the unique

sl.ensureArray(“L_TYPE “A”\r\nL_TYPE “A”\r\nL_TYPE “A”\r\nL_TYPE “B”\r\nL_TYPE “B”\r\nL_TYPE “B”\r\nL_TYPE “C”\r\nL_TYPE “C”\r\nL_TYPE “C”\r\nL_TYPE “D”\r\nL_TYPE “D”\r\nL_TYPE “D””.match(/L_TYPE “C”/gm)).filter((a,b,c)=> c.indexOf(a) == b).join()