Dealing with a rather intricate and detailed JSON structure, I have a specific extraction task at hand.
The goal is to retrieve information (text) from the JSON only if the resource-id
includes the text
"com.shazam.android:id/"
and certain properties (["title", "subtitle", "datetime"]
) are present.
If the last element does not contain a datetime
, then resorceIdFinal
should not be included.
Below is a sample JSON that illustrates what I am aiming to achieve.
You can access the JSON I am working with through this link: https://pastebin.com/raw/hFLmP2T8
// JavaScript code snippets...
// Function to check presence of keys in an object
const check = (obj, keys) => !keys.some((el) => !obj.hasOwnProperty(el));
// Function to check if an object is empty
const isObjectEmpty = (objectName) => {
return (
objectName &&
Object.keys(objectName).length === 0 &&
objectName.constructor === Object
);
};
// More functions related to processing the JSON data...
The desired JSON output:
[
{
"title": "Believe",
"subtitle": "Chuther",
"datetime": "12 giu, 16:42"
},
// Additional JSON objects...
]
Your assistance would be greatly appreciated!
Edit:
// Updated JavaScript code snippet...
// Function to check if an object is empty
const isObjectEmpty = (objectName) =>
(
objectName &&
Object.keys(objectName).length === 0 &&
objectName.constructor === Object
);
// More updated functions for extracting information from JSON data...