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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews