Etlevi

Etlevi

I have a huge JSON file and what I want to accomplish is tell if there are any dupes in this json and which ones. This is basically to check if the JSON responses from a log are having duplicates or no hence verify if what the API is returning looks good. I have read about Enum.uniq but I am not sure if that is something that would do my case. I would appreciate any hints or suggestions.

Thanks in advance

Showing Posts 1 to 4

dimitarvp

dimitarvp

Your question is a bit open-ended. It will help if you post some small JSON samples demonstrating the (un-)desirable cases.

Furthermore, do you strictly need this in Elixir? Tools like jq and gron are 99% likely to do the job.

Etlevi

Etlevi OP

I have seen there are some tools out there but I don’t want to make use of those as from one I tried there certain limitations. I am not sure if those you mention have similar limitations. Does it mean it’s hard to do it in Elixir?

I am only including a small part as it is huge and I don’t know if I can paste all that stuff here since I am not allowed to upload anyway:

{
  "deals": [
    {
      "hash": "497281f9",
      "owner": "1",
      "contact": "8",
      "organization": null,
      "group": "1",
      "stage": "2",
      "title": "Bono",
      "description": "",
      "percent": "0",
      "cdate": "2023-12-18T15:04:54-06:00",
      "mdate": "2023-12-18T15:04:54-06:00",
      "nextdate": null,
      "nexttaskid": null,
      "value": "9999900",
      "currency": "usd",
      "winProbability": null,
      "winProbabilityMdate": "2023-12-18T15:04:54-06:00",
      "status": "0",
      "activitycount": "2",
      "nextdealid": "569",
      "edate": "2023-12-18 15:11:06",
      "links": {
        "dealActivities": "https://avucon71549.api-us1.com/api/3/deals/6/dealActivities",
        "contact": "https://avucon71549.api-us1.com/api/3/deals/6/contact",
        "contactDeals": "https://avucon71549.api-us1.com/api/3/deals/6/contactDeals",
        "group": "https://avucon71549.api-us1.com/api/3/deals/6/group",
        "nextTask": "https://avucon71549.api-us1.com/api/3/deals/6/nextTask",
        "notes": "https://avucon71549.api-us1.com/api/3/deals/6/notes",
        "account": "https://avucon71549.api-us1.com/api/3/deals/6/account",
        "customerAccount": "https://avucon71549.api-us1.com/api/3/deals/6/customerAccount",
        "organization": "https://avucon71549.api-us1.com/api/3/deals/6/organization",
        "owner": "https://avucon71549.api-us1.com/api/3/deals/6/owner",
        "scoreValues": "https://avucon71549.api-us1.com/api/3/deals/6/scoreValues",
        "stage": "https://avucon71549.api-us1.com/api/3/deals/6/stage",
        "tasks": "https://avucon71549.api-us1.com/api/3/deals/6/tasks",
        "dealCustomFieldData": "https://avucon71549.api-us1.com/api/3/deals/6/dealCustomFieldData"
      },
      "id": "6",
      "isDisabled": false,
      "account": null,
      "customerAccount": null
    },
    {
      "hash": "8efe4b41",
      "owner": "1",
      "contact": "7",
      "organization": "2",
      "group": "1",
      "stage": "3",
      "title": "Leke",
      "description": "",
      "percent": "0",
      "cdate": "2023-12-18T15:04:01-06:00",
      "mdate": "2023-12-18T15:11:00-06:00",
      "nextdate": null,
      "nexttaskid": "0",
      "value": "1000000",
      "currency": "usd",
      "winProbability": null,
      "winProbabilityMdate": "2023-12-18T15:04:01-06:00",
      "status": "0",
      "activitycount": "2",
      "nextdealid": "6",
      "edate": "2023-12-18 15:10:53",
      "links": {
        "dealActivities": "https://avucon71549.api-us1.com/api/3/deals/5/dealActivities",
        "contact": "https://avucon71549.api-us1.com/api/3/deals/5/contact",
        "contactDeals": "https://avucon71549.api-us1.com/api/3/deals/5/contactDeals",
        "group": "https://avucon71549.api-us1.com/api/3/deals/5/group",
        "nextTask": "https://avucon71549.api-us1.com/api/3/deals/5/nextTask",
        "notes": "https://avucon71549.api-us1.com/api/3/deals/5/notes",
        "account": "https://avucon71549.api-us1.com/api/3/deals/5/account",
        "customerAccount": "https://avucon71549.api-us1.com/api/3/deals/5/customerAccount",
        "organization": "https://avucon71549.api-us1.com/api/3/deals/5/organization",
        "owner": "https://avucon71549.api-us1.com/api/3/deals/5/owner",
        "scoreValues": "https://avucon71549.api-us1.com/api/3/deals/5/scoreValues",
        "stage": "https://avucon71549.api-us1.com/api/3/deals/5/stage",
        "tasks": "https://avucon71549.api-us1.com/api/3/deals/5/tasks",
        "dealCustomFieldData": "https://avucon71549.api-us1.com/api/3/deals/5/dealCustomFieldData"
 },
      "id": "556",
      "isDisabled": false,
      "account": "1",
      "customerAccount": "1"
    }
  ],
  "meta": {
    "currencies": {
      "USD": {
        "total": "569",
        "value": "11136200",
        "currency": "USD",
        "isDisabled": false
      }
    },
    "total": 569
  }
}

Appreciate your help. Thanks!

lud

lud

Do you want to see if there are duplicates in the deals array? If not, can you make up and example of json with duplicates? It does not have to be actual secret data.

Look at Enum.group_by/3 or Enum.frequencies/1

dimitarvp

dimitarvp

It’s 99% likely it’s doable just fine in Elixir, I’m simply asking what’s your time budget i.e. how quickly you should deliver. If it has to be done yesterday then the CLI tools have your back.

And please respond to the previous poster’s question. Show us a list of 5 records of which 2 are duplicates. You can cut most of the fields so the snippet here is not huge. Let’s see what makes records duplicates.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews