Skip to main content

Questions tagged [json]

JSON (JavaScript Object Notation) aka the Fat Free Alternative to XML is a lightweight data exchange format inspired by JavaScript object literals. It is often used with JavaScript, Ajax, and RESTful web services but is completely language independent.

Filter by
Sorted by
Tagged with
6 votes
4 answers
710 views

JSON data format for MCQ data bank

I'm creating a data bank of MCQ (Multi Choice Questions) and their answers so that an app can be built around it. Regarding the actual storage format, I have two ideas: An array of objects with keys (...
3 votes
1 answer
426 views

Deterministically hash dictionary

I need to compute a deterministic hash for a JSON-serializable dictionary. This answer almost does the job, but there are a few problems. If dict1 == dict2 then I ...
1 vote
0 answers
131 views

Json4 parser in Typescript - Optimized

Context This review-request is a follow-up to this question. After the initial implementation, which focused on spec-compliance mainly, I have made some revisions to improve the performance of the ...
0 votes
1 answer
72 views

Feedback for my first project - sqlserver-json-tools

could you review my first project on github please. The JSON_MODIFY function in SQL Server 2016 and 2019 does not allow creating paths dynamically, making it necessary to chain JSON_MODIFY executions. ...
3 votes
1 answer
1k views

Insert json object into existing Json array

I have created a tool to insert JSON objects with several rules: Read the product status, and then insert based on the status If there is no data in this status, then insert the object If there is ...
4 votes
1 answer
237 views

Perl Nagios plugin to query an API, obtain date from JSON, and determine if the date is within thresholds

This is an update of Using an API to obtain JSON data and get the date string and determine if data is stale This is a Nagios check that will use an API URL, get JSON data, flatten the data into a ...
3 votes
1 answer
59 views

PowerShell Script for Parsing JSON PyPI Package Data and find the latest version

Following this post, I have a PowerShell script that aims to interact with the Python Package Index (PyPI) to find the latest release of a specified package that is compatible with the current Python ...
6 votes
2 answers
883 views

Extract data from api using shell scripting

So we have many vlans at work, often it is nice to see which ip ranges are associated with said vlan. We have a well developed api for displaying information about our network and thus I wrote a small ...
4 votes
2 answers
90 views

Serial copying from disk images to folder in Bash

This is a Bash script that copies files stored inside disk images to a directory, using a defined structure provided via a JSON file. I've included the external programs it requires and the test I ...
4 votes
1 answer
95 views

Extracting domains and IPs from Exodus trackers JSON report

The following command series is used to gather every bit of valuable information from Exodus trackers. The ultimate goal would be to get this all into one jq ...
4 votes
1 answer
146 views

Find download URL for a package, from almost-JSON with substitutions

I have an almost-JSON document in a file named versions.json. It looks like this: ...
3 votes
1 answer
288 views

Bash scripts to convert json to associative arrays and then back to json

I'm a relative bash novice but have found it along with jq a great way to manipulate json scraped from various sources. I couldn't find any ready-made scripts to convert arbitrarily deep json to bash ...
6 votes
1 answer
41k views

Replacing values in json file with jq

I have a JSON file like ...
4 votes
1 answer
87 views

Java classes for downloading all in-coming/out-going links of an article in the Wikipedia article graph

(The entire project is in GitHub.) Introduction This project provides facilities for generating in-coming or out-going links in a given Wikipedia page. Code ...
0 votes
1 answer
43 views

Updating class method to use data from new weather API endpoint while keeping same return value object structure as with old endpoint

I needed to update a class in Node.js that parses the response from a new weather API endpoint but still preserves the same object structure and key values from having been using the old weather API ...
4 votes
2 answers
121 views

Fetch a Quranic Verse from the Web

Verse is a command-line program that allows you to retrieve specific verses from the Quran. It takes a chapter and verse number as input and provides you with the corresponding Quranic verse. ...
6 votes
1 answer
673 views

Decoding a JSON dictionary into different Swift classes using Decodable and JSONDecoder

Generally, the approach I've taken is to try calling container.decode from a decodable enum with its associated value returning ...
1 vote
0 answers
35 views

caching and rendering blog posts in markdown in react

I'd like to know if I'm doing this badly or involving any antipatterns. Masterlist.json contains a list full of all of the posts that exist and should be fetched on the page. Post metadata is ...
1 vote
0 answers
103 views

Better way to parse data from nested JSON in Javascript/ NextJS

The nested JSON file contains names of US states and corresponding cities. City.json ...
5 votes
1 answer
1k views

Objective C String to JSON formatting

Quick disclaimer. I've programmed Java for years but this is the first Objective C I've ever written. I've written some code which almost unfortunately works but frankly hurts my eyes with the number ...
1 vote
1 answer
285 views

Extracting data stored in a JsonDocument from an Excel file on sharepoint.com, retrieved using Microsoft Graph

I retrieve data from an Excel file located on sharepoint.com using Microsoft.Graph like this: ...
3 votes
1 answer
254 views

Find the closest named color

I have a .json file with name (string) and RGB (r, g, b: numbers) with 30.000 key-value pairs. I am looping the json multiple times per second to find the closest name to a given RGB color. Any idea ...
3 votes
1 answer
161 views

parsing json file with potential corrupted record and sorting by id to output first n lines - cleaner logic

messy json file is parsed and should output the N highest record IDs & scores by score in descending order, highest score first. the code works but i wonder if there is better readability, help me ...
8 votes
5 answers
17k views

Using argparse with parameters defined in config file

I understand that and why using eval is generally considered bad practice in most cases (see e.g. here). Related questions on config files and argparse don't use ...
1 vote
0 answers
166 views

Wrapping an ExpandoObject within a SafeExpandoObject

I've written code to deserialize a JSON into an ExpandoObject. The only problem with the ExpandoObject is that if you try to access a member which doesn't exist, it ...
1 vote
2 answers
93 views

Update JSON object in outer object or insert a default one

The below code is part of a program that, among other things, configures a Chromium profile: ...
0 votes
0 answers
33 views

Modala creates website from nested JSONs

My question pertains to the style in which I've written this function. Is there anything else I can do, to create a better resolution for user when they create a template from their JSON modal? This ...
3 votes
2 answers
178 views

Enum to deserialize HTML sizes from JSON with serde

I added an enum for my webscraper to deserialize data from a JSON field that represents an HTML image size, which can either be an unsigned int like 1080 or a ...
-1 votes
1 answer
120 views

Using JavaScript to interface with REST APIs

The website TryHackMe came up with a challenge that involves using HTTP requests to interface with REST APIs (here, task #14/day 9). The challenge basically involves querying a basic REST API to ...
26 votes
4 answers
8k views

Filtering a large (50gb+) JSON lines file matching CIDR's

I'm trying to speed up a Python script that reads a large log file (JSON lines, 50gb+) and filter out results that match 1 of 2000 CIDR ranges. Logfile 20 million lines ...
3 votes
1 answer
278 views

JSON comparison function

I've written a comparison function between two json values. I'd like to know if it can be improved at all in any way. Thanks again for the help. ...
1 vote
0 answers
23 views

Designing a font definition with multiple variants per glyph

My project penhand tries to visualize the process of writing with a pen. Part of the project is an engine that converts text entry into a sequence of glyphs that are then rendered as animation into a ...
1 vote
0 answers
24 views

Use API data to ensure current product prices in database data then sort by price

Because I've waited until now to bother learning the magical JSON functions that modern MYSQL affords, I wonder if my code is optimally written and if there are cautions/limitations to be aware of. My ...
0 votes
2 answers
2k views

Best Practice: creating a nested associative array JSON in PHP

It's been a while I have been on here and I hope I still understand the rules😊. I have recently started learning PHP and WordPress for a Whatsapp Chatbot integration. I have created a webhook on my ...
1 vote
2 answers
413 views

group countries by language in JavaScript

I need a better implementation than the below code (O(N) Solution), I am grouping countries by language ( data ) is the countries JSON, each country could have 0, 1 .. or more language as the object ...
3 votes
1 answer
849 views

"Fixing" broken JSON with unescaped quotes

This code is supposed to fix JSON structures that are broken by having unescaped quotes in strings and try to recover if possible. The code can only recover on certain cases and can be fooled by ...
4 votes
2 answers
3k views

Download entire localStorage as file

I would like to download the entire contents from localStorage to a json file (in a "clear" formatting). I've tried this and it works perfectly. However, ...
2 votes
0 answers
145 views

Python raw dataclass to formatted dataclass transformation for avro schema

I receive some data from an api. I would like to define the raw responses schema and model it as a python dataclass, with the added benefit of using the ...
4 votes
1 answer
1k views

JSON value with std::variant

For learning purposes, I wanted to implement a class that could hold JSON data with std::variant. Most of the implementations I found online were using incomplete types as template arguments for map, ...
4 votes
1 answer
401 views

Parse json manually to POCO classes

I have below json which I need to deserialize in C# - ...
2 votes
0 answers
121 views

Python code to add GeoIP data to a Suricata eve.json log

I wrote this script as part of a Suricata course where I had to annotate destination IP addresses with GeoIP data in an EVE JSON log file. I would like your input on my code style and smell, ...
2 votes
2 answers
2k views

Created structured/nested JSON from unstructured JSON

I have below unstructured but valid JSON which need to be converted to structured format ...
3 votes
1 answer
52 views

Optimizing code for this function that filters a JSON file

I made a function that turns all child from a JSON file to parents (or brothers?). It adds the parent name to the key, so there are no duplicates. It works ok, but I would like to ask if there are ...
2 votes
2 answers
89 views

delete multidimentional array value in php

I made a program that converts JSON to a PHP array and checks every value of the multidimensional array with a loop and if a value matches certain values then it deletes that key and value and ...
2 votes
2 answers
640 views

Apply a schema validation against an HTTP request with JSON body

...
2 votes
1 answer
76 views

Implementation of JSON schem parser to extract some attributes

I have three different types of schema possibilities as below: ...
0 votes
1 answer
48 views

Iterating over JSON more effectively

Problem: I need to get data from JSON file containing information about "contributors". Each contributor has an atrribute jobs, which is a list of string-...
3 votes
2 answers
89 views

Saving and reading the last successful execution as a json-file

I've got some tools that run perdiodically like weekly or monthly that don't support any retry mechanism. In order to increase their chance to succeed in case a database wasn't reachable or some other ...
2 votes
1 answer
192 views

Merges two OKHTTP responses into one

The first request is sent asynchronously, then the id value is taken from the response to the first request and used in the second asynchronous request. And then both responses to request 1 and ...
4 votes
1 answer
65 views

Generating a randomized JSON for testing RabbitMQ

The following code will be used to generate a random json object to be used as a RabbitMQ message body. The code works but I'm sure it can be improved in ways that I am not seeing, as I am a novice. ...

1
2 3 4 5
18