Retrieving the "Link_ID" within an API - json

I am using the Reddit API called Pushshift (https://github.com/pushshift/api)
I am trying to get the "LINK_ID" for Reddit post based on the title of the search.
For example, I want to find out all Reddit posts that contain the word "Trump" in the title - and I want to get the LINK_ID for each one of these posts. When I search : https://api.pushshift.io/reddit/search/submission/?title=trump
I get the following results:
"data": [
{
"all_awardings": [],
"allow_live_comments": false,
"author": "rajacreator",
"author_flair_css_class": null,
"author_flair_richtext": [],
"author_flair_text": null,
"author_flair_type": "text",
"author_fullname": "t2_ouuxidx4",
"author_is_blocked": false,
"author_patreon_flair": false,
"author_premium": false,
"awarders": [],
"can_mod_post": false,
"contest_mode": false,
"created_utc": 1663481539,
"domain": "rajacreator.com",
"full_link": "https://www.reddit.com/r/news/comments/xh8ui0/servants_of_the_damned_overview_trump_and_the/",
"gildings": {},
"id": "xh8ui0",
"is_created_from_ads_ui": false,
"is_crosspostable": false,
"is_meta": false,
"is_original_content": false,
"is_reddit_media_domain": false,
"is_robot_indexable": false,
"is_self": false,
"is_video": false,
"link_flair_background_color": "",
"link_flair_richtext": [],
"link_flair_text_color": "dark",
"link_flair_type": "text",
"locked": false,
"media_only": false,
"no_follow": true,
"num_comments": 0,
"num_crossposts": 0,
"over_18": false,
"parent_whitelist_status": "all_ads",
"permalink": "/r/news/comments/xh8ui0/servants_of_the_damned_overview_trump_and_the/",
"pinned": false,
"pwls": 6,
"removed_by_category": "automod_filtered",
"retrieved_on": 1663481550,
"score": 1,
"selftext": "",
"send_replies": false,
"spoiler": false,
"stickied": false,
"subreddit": "news",
"subreddit_id": "t5_2qh3l",
"subreddit_subscribers": 25211187,
"subreddit_type": "public",
"thumbnail": "default",
"title": "Servants of the Damned overview: Trump and the giant law firm he actually paid",
"total_awards_received": 0,
"treatment_tags": [],
"upvote_ratio": 1.0,
"url": "https://rajacreator.com/servants-of-the-damned-review-trump-and-the-giant-law-firm-he-actually-paid/?utm_source=SocialAutoPoster",
"url_overridden_by_dest": "https://rajacreator.com/servants-of-the-damned-review-trump-and-the-giant-law-firm-he-actually-paid/?utm_source=SocialAutoPoster",
"whitelist_status": "all_ads",
"wls": 6
},
There seems to be nothing here about "LINK_ID".
Can someone please show me how to get the LINK_ID?
Thank you!
Note: In the future - once I find the LINK_ID for a specific Reddit link, I would then like to extract all the comments posted for that Reddit link (e.g. https://www.reddit.com/r/pushshift/comments/bcwqxb/get_all_comments_from_submission/)

Related

Looping a nesty struture in Coldfusion [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
Here is my JSON Data:
This i am trying to loop and get all the information about every node of it with the key name and the key data
{
"src": 1,
"feeds": [{
"id": 1,
"name": "All",
"polarPlot": true
}],
"srcFeed": 1,
"showSil": true,
"showFlg": true,
"showPic": true,
"flgH": 20,
"flgW": 85,
"acList": [{
"Id": 12589424,
"Rcvr": 1,
"HasSig": false,
"Icao": "C01970",
"Bad": false,
"Reg": "C-FJQL",
"FSeen": "\/Date(1672216397120)\/",
"TSecs": 334,
"CMsgs": 330,
"Alt": 34975,
"GAlt": 35206,
"InHg": 30.15059,
"AltT": 0,
"Call": "ROU1958",
"Lat": 45.59019,
"Long": -74.90746,
"PosTime": 1672216731130,
"Mlat": false,
"Tisb": false,
"Spd": 469.0,
"Trak": 59.3,
"TrkH": false,
"Type": "A321",
"Mdl": "Airbus A321 211SL",
"Man": "Airbus",
"CNum": "7117",
"From": "YYZ Lester B. Pearson, Toronto, Canada",
"To": "YQB Quebec Jean Lesage, Canada",
"Op": "Air Canada Rouge",
"OpIcao": "ROU",
"Sqk": "2222",
"Help": false,
"Vsi": 0,
"VsiT": 0,
"WTC": 2,
"Species": 1,
"Engines": "2",
"EngType": 3,
"EngMount": 0,
"Mil": false,
"Cou": "Canada",
"HasPic": false,
"Interested": false,
"FlightsCount": 2,
"Gnd": false,
"SpdTyp": 0,
"CallSus": false,
"Trt": 2,
"Year": "2016"
}, {
"Id": 12595324,
"Rcvr": 1,
"HasSig": false,
"Icao": "C0307C",
"Bad": false,
"Reg": "C-FSJJ",
"FSeen": "\/Date(1672215986531)\/",
"TSecs": 745,
"CMsgs": 284,
"Alt": 35000,
"GAlt": 35189,
"InHg": 30.1092529,
"AltT": 0,
"Call": "ACA394",
"Lat": 47.86931,
"Long": -72.90211,
"PosTime": 1672216731064,
"Mlat": false,
"Tisb": false,
"Spd": 513.0,
"Trak": 117.2,
"TrkH": false,
"Type": "B38M",
"Mdl": "Boeing 737MAX 8",
"Man": "Boeing",
"CNum": "61217",
"From": "YYC Calgary, Canada",
"To": "YHZ Halifax / Stanfield, Canada",
"Op": "Air Canada",
"OpIcao": "ACA",
"Sqk": "1144",
"Help": false,
"Vsi": 0,
"VsiT": 0,
"WTC": 2,
"Species": 1,
"Engines": "2",
"EngType": 3,
"EngMount": 0,
"Mil": false,
"Cou": "Canada",
"HasPic": false,
"Interested": false,
"FlightsCount": 2,
"Gnd": false,
"SpdTyp": 0,
"CallSus": false,
"Trt": 2,
"Year": "2018"
}, {
"Id": 12601386,
"Rcvr": 1,
"HasSig": false,
"Icao": "C0482A",
"Bad": false,
"Reg": "C-GBIN",
"FSeen": "\/Date(1672215747131)\/",
"TSecs": 984,
"CMsgs": 5124,
"Alt": 32925,
"GAlt": 33185,
"InHg": 30.1801186,
"AltT": 0,
"Call": "ROU1689",
"Lat": 45.119546,
"Long": -71.834575,
"PosTime": 1672216731191,
"Mlat": false,
"Tisb": false,
"Spd": 462.5,
"Trak": 31.1,
"TrkH": false,
"Type": "A319",
"Mdl": "Airbus A319 114",
"Man": "Airbus",
"CNum": "845",
"From": "FLL Fort Lauderdale Hollywood, United States",
"To": "YQB Quebec Jean Lesage, Canada",
"Op": "Air Canada Rouge",
"OpIcao": "ROU",
"Sqk": "1447",
"Help": false,
"Vsi": -2112,
"VsiT": 0,
"WTC": 2,
"Species": 1,
"Engines": "2",
"EngType": 3,
"EngMount": 0,
"Mil": false,
"Cou": "Canada",
"HasPic": false,
"Interested": false,
"FlightsCount": 1,
"Gnd": false,
"SpdTyp": 0,
"CallSus": false,
"Trt": 2,
"Year": "1998"
}, {
"Id": 10812570,
"Rcvr": 1,
"HasSig": false,
"Icao": "A4FC9A",
"Bad": false,
"Reg": "N420LA",
"FSeen": "\/Date(1672215081608)\/",
"TSecs": 1650,
"CMsgs": 4226,
"Alt": 34000,
"GAlt": 34281,
"InHg": 30.2007866,
"AltT": 0,
"Call": "LAE2512",
"Lat": 46.00371,
"Long": -71.20912,
"PosTime": 1672216731894,
"Mlat": false,
"Tisb": false,
"Spd": 399.0,
"Trak": 210.7,
"TrkH": false,
"Type": "B763",
"Mdl": "Boeing 767 316F/W",
"Man": "Boeing",
"CNum": "34627",
"Op": "MAS Air Cargo",
"OpIcao": "MAA",
"Sqk": "0706",
"Help": false,
"Vsi": 0,
"VsiT": 0,
"WTC": 3,
"Species": 1,
"Engines": "2",
"EngType": 3,
"EngMount": 0,
"Mil": false,
"Cou": "United States",
"HasPic": false,
"Interested": false,
"FlightsCount": 1,
"Gnd": false,
"SpdTyp": 0,
"CallSus": false,
"Trt": 2,
"Year": "2006"
}, {
"Id": 12706028,
"Rcvr": 1,
"HasSig": false,
"Icao": "C1E0EC",
"Bad": false,
"FSeen": "\/Date(1672196473179)\/",
"TSecs": 20258,
"CMsgs": 1605,
"Alt": 125300,
"GAlt": 125300,
"AltT": 0,
"Call": "TEST1234",
"Tisb": false,
"TrkH": false,
"Sqk": "",
"VsiT": 0,
"WTC": 0,
"Species": 0,
"EngType": 0,
"EngMount": 0,
"Mil": false,
"Cou": "Canada",
"HasPic": false,
"Interested": false,
"FlightsCount": 4,
"Gnd": false,
"SpdTyp": 0,
"CallSus": false,
"Trt": 1
}],
"totalAc": 5,
"lastDv": "638077811342841157",
"shtTrlSec": 30,
"stm": 1672216731909
}
I am trying to loop and have the data for every loop in the nesty structure
As depending on the plane info, data is often changed fopr more or less inside nesty loop
I have tried everything on my low knowledge of coldfusion
Need some help and many thanks to all
Save it as a variable, then deserialize.
<cfset JSONObject = DeserializeJSON(YourVariable)>
You can then call specific key-values from it like #JSONObject.flgH#.
If you have multiple to loop through you can output it with array notation, like #JSONObject.acList.Reg[1]# - you would replace the number with a variable like [i] if you're looping through it dynamically.
You can start with:
<cfset local.stData = deserializeJSON(whatever that variable is holding the JSON) />
<!--- Now, local.stData.acList is what is called "an array of structs" --->
<cfloop array="#local.stData.acList#" index="local.n" item="local.stPlane">
<!--- In here, you can work with local.stPlane.id, for example --->
<!--- If you need to loop over the "keys" of the struct, like "Id", "Rcvr", you can do that, too. I prefer structKeyList --->
<cfloop list="#structKeyList(local.stPlane)#" index="local.sKey">
<cfif local.sKey = 'Id'>
<cfelseif local.sKey = 'Rcvr'>
</cfif>
<!--- Or... --->
<cfswitch expression="#local.sKey#">
<cfcase value="Id">
</cfcase>
<cfcase value="Rcvr">
</cfcase>
<cfdefaultcase>
<!--- For unexpected keys, or just skip this block --->
</cfdefaultcase>
</cfswitch>
</cfloop>
</cfloop>

Nested Json data to postgresql using python

How can i import my json file to a postgresql using python my data will look likes
{
"blocked_by": false,
"blocking": false,
"contributors_enabled": false,
"created_at": "Thu Dec 17 06:32:35 +0000 2020",
"default_profile": true,
"default_profile_image": false,
"description": "seo",
"entities": {
"description": {
"urls": []
}
},
"favourites_count": 12,
"follow_request_sent": false,
"followers_count": 56,
"following": false,
"friends_count": 1344,
"geo_enabled": false,
"has_extended_profile": true,
"id": 1339458394508374018,
"id_str": "1339458394508374018",
"is_translation_enabled": false,
"is_translator": false,
"lang": null,
"listed_count": 3,
"live_following": false,
"location": "",
"muting": false,
"name": "katheryn myle",
"notifications": false,
"profile_background_color": "F5F8FA",
"profile_background_image_url": null,
"profile_background_image_url_https": null,
"profile_background_tile": false,
"profile_image_url": "http://pbs.twimg.com/profile_images/1343124937389842432/30cfUmGe_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1343124937389842432/30cfUmGe_normal.jpg",
"profile_link_color": "1DA1F2",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "KatherynMyle",
"status": {
"contributors": null,
"coordinates": null,
"created_at": "Tue Apr 05 10:17:04 +0000 2022",
"entities": {
"hashtags": [],
"symbols": [],
"urls": [
{
"display_url": "twitter.com/i/web/status/1\u2026",
"expanded_url": "https://twitter.com/i/web/status/1511286791319564293",
"indices": [
117,
140
],
"url": "shortened url"
}
],
"user_mentions": [
{
"id": 2247373052,
"id_str": "2247373052",
"indices": [
0,
12
],
"name": "GDevelop",
"screen_name": "GDevelopApp"
}
]
},
"favorite_count": 0,
"favorited": false,
"geo": null,
"id": 1511286791319564293,
"id_str": "1511286791319564293",
"in_reply_to_screen_name": "GDevelopApp",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": 2247373052,
"in_reply_to_user_id_str": "2247373052",
"is_quote_status": false,
"lang": "en",
"place": null,
"retweet_count": 0,
"retweeted": false,
"source": "Twitter Web App",
"text": "#GDevelopApp Hello\nHow are you fine I am a link builder and we are selling links and posts on high-quality sites if\u2026 ",
"truncated": true
},
"statuses_count": 382,
"time_zone": null,
"translator_type": "none",
"url": null,
"utc_offset": null,
"verified": false,
"withheld_in_countries": []
I want to create a table with it have ing the index or key name as the column name and also i want only some index data from it not all (like utc _offset,place,etc.).so i want to insert the specific data i wanted to postgresql
https://drive.google.com/file/d/1OkJFfHyU4Eb-V3mrU2qJ_jwBaQQkunJa/view?usp=drivesdk this is the json file
Your question is very vague and I can't come up with a short answer except this one:
pSQL does support JSON as a data type:
https://www.postgresql.org/docs/current/datatype-json.html
https://www.postgresql.org/docs/current/functions-json.html
You could just store the whole json as a single json element and select/convert/whatever within postgre later on.
How to insert JSONB into Postgresql with Python?

Azure Congnitive Service Skill not persisting custom skill value

I have create a custom skill for my Azure Cognitive Service. After creating the datasouce, index, indexer and running the indexer I can see that my function is being called and it is outputting the correct information, but when I search the index the field that is connected to the custom skill is empty.
This is my indexer definition:
{
"name": "idxdocs",
"description": null,
"dataSourceName": "dsdocs",
"skillsetName": "skillset-procuradores",
"targetIndexName": "customer-documents",
"disabled": null,
"schedule": null,
"parameters": {
"batchSize": null,
"maxFailedItems": -1,
"maxFailedItemsPerBatch": null,
"base64EncodeKeys": null,
"configuration": {
"indexedFileNameExtensions": ".pdf,.docx,.doc",
"dataToExtract": "contentAndMetadata",
"failOnUnprocessableDocument": false,
"failOnUnsupportedContentType": false,
"indexStorageMetadataOnlyForOversizedDocuments": true,
"allowSkillsetToReadFileData": true
}
},
"fieldMappings": [],
"outputFieldMappings": [
{
"sourceFieldName": "/document/content/procuradores",
"targetFieldName": "procuradores"
}
],
"cache": null,
"encryptionKey": null
}
This is my index:
{
"name": "customer-documents",
"fields": [
{
"name": "key",
"type": "Edm.String",
"facetable": true,
"filterable": true,
"key": true,
"retrievable": true,
"searchable": false,
"sortable": true,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "content",
"type": "Edm.String",
"facetable": false,
"filterable": false,
"key": false,
"retrievable": true,
"searchable": true,
"sortable": false,
"analyzer": "es.lucene",
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "procuradores",
"type": "Edm.String",
"facetable": false,
"filterable": true,
"key": false,
"retrievable": true,
"searchable": false,
"sortable": false,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
}
],
"suggesters": [],
"scoringProfiles": [],
"defaultScoringProfile": null,
"corsOptions": null,
"analyzers": [],
"charFilters": [],
"tokenFilters": [],
"tokenizers": [],
"similarity": {
"#odata.type": "#Microsoft.Azure.Search.BM25Similarity",
"k1": null,
"b": null
},
"encryptionKey": null,
"#odata.etag": "\"0x8D98BC85E9F6996\""
}
My skill set definition:
{
"name": "skillset-procuradores",
"description": "",
"skills": [
{
"#odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
"name": "procuradores",
"description": "",
"context": "/document",
"uri": "my url ommited for secure reasons",
"httpMethod": "POST",
"timeout": "PT3M50S",
"batchSize": 1,
"degreeOfParallelism": null,
"inputs": [
{
"name": "text",
"source": "/document/content"
}
],
"outputs": [
{
"name": "procuradores",
"targetName": "procuradores"
}
],
"httpHeaders": {}
}
],
"cognitiveServices": null,
"knowledgeStore": null,
"encryptionKey": null
}
And finally my function output:
{
"values": [
{
"recordId": "1",
"data": {
"procuradores": "people's names"
}
}
]
}
What am I missing?
Rafael, can you give debug sessions a try? I suspect there is something happening in your custom skill that means the data is not coming back. By using this, you can test the actual input and output.
https://learn.microsoft.com/en-us/azure/search/cognitive-search-debug-session
This is just a hunch, but in the indexer definition, try changing your output field mapping sourceFieldName from "/document/content/procuradores" to "/document/procuradores". The context that you are giving in the skill is just "/document" so it should append the output onto that.

I trying to create a DB schema based on a JSON file

I am trying to create a DB based on a JSON file but I am messing up the keys and references. Can you guys have a look and tell me whats wrong with the create statement?
The json files are basically reviews or comments from people and there are 7 response objects and one cursor object in this json file.
JSON file:
{
"cursor": {
"prev": null,
"hasNext": false,
"next": "1542275432008325:1:0",
"hasPrev": false,
"total": null,
"id": "1542275432008325:1:0",
"more": false
},
"code": 0,
"response": [
{
"editableUntil": "2018-11-22T11:20:37",
"dislikes": 0,
"numReports": 0,
"likes": 1,
"message": "<p>A sinking pound, resignations by the bucketful railroading through a so-called agreement nobody wants. For the good of the country Mrs. May 'go and go now'.</p>",
"id": "4196155749",
"createdAt": "2018-11-15T11:20:37",
"author": {
"username": "mnaid-233509073ed3432027d48b1a83f5fbd2",
"about": "",
"name": "baggiebuoy",
"disable3rdPartyTrackers": true,
"isPowerContributor": false,
"joinedAt": "2017-05-03T10:40:52",
"profileUrl": "https://disqus.com/by/mnaid-233509073ed3432027d48b1a83f5fbd2/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "250728493",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-233509073ed3432027d48b1a83f5fbd2.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-233509073ed3432027d48b1a83f5fbd2.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-233509073ed3432027d48b1a83f5fbd2.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": null,
"isApproved": true,
"isFlagged": false,
"raw_message": "A sinking pound, resignations by the bucketful railroading through a so-called agreement nobody wants. For the good of the country Mrs. May 'go and go now'.",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 1,
"moderationLabels": [],
"isEdited": true,
"sb": false
},
{
"editableUntil": "2018-11-22T10:37:59",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>This could be heaven, or this could be hell.</p>",
"id": "4196048572",
"createdAt": "2018-11-15T10:37:59",
"author": {
"username": "mnaid-29e1c59be16c852670e3be302e8c303b",
"about": "",
"name": "Mordecai",
"disable3rdPartyTrackers": false,
"isPowerContributor": false,
"joinedAt": "2017-05-03T13:01:02",
"profileUrl": "https://disqus.com/by/mnaid-29e1c59be16c852670e3be302e8c303b/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "250739494",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": 4196013534,
"isApproved": true,
"isFlagged": false,
"raw_message": "This could be heaven, or this could be hell.",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
},
{
"editableUntil": "2018-11-22T10:36:50",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>The crappest of crap deals.<br>Will never get through Parliament.</p><p>You are the weakest link May, goodbye.</p>",
"id": "4196044068",
"createdAt": "2018-11-15T10:36:50",
"author": {
"username": "mnaid-29e1c59be16c852670e3be302e8c303b",
"about": "",
"name": "Mordecai",
"disable3rdPartyTrackers": false,
"isPowerContributor": false,
"joinedAt": "2017-05-03T13:01:02",
"profileUrl": "https://disqus.com/by/mnaid-29e1c59be16c852670e3be302e8c303b/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "250739494",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-29e1c59be16c852670e3be302e8c303b.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": null,
"isApproved": true,
"isFlagged": false,
"raw_message": "The crappest of crap deals.\nWill never get through Parliament.\n\nYou are the weakest link May, goodbye.",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
},
{
"editableUntil": "2018-11-22T10:28:13",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>We are all just prisoners here of our own device. 😁</p>",
"id": "4196013534",
"createdAt": "2018-11-15T10:28:13",
"author": {
"username": "mnaid-42ba513c42a0fd6558aa44b1de658140",
"about": "",
"name": "chaffwolf",
"disable3rdPartyTrackers": true,
"isPowerContributor": false,
"joinedAt": "2017-12-20T16:45:10",
"profileUrl": "https://disqus.com/by/mnaid-42ba513c42a0fd6558aa44b1de658140/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "274657487",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": 4195981074,
"isApproved": true,
"isFlagged": false,
"raw_message": "We are all just prisoners here of our own device. 😁",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
},
{
"editableUntil": "2018-11-22T10:27:03",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>Should be no deal end off.<br>Nobody could possibly be the winner so it's simple leave and that's it .<br>Their will always be wannabes who think they can do better in it for only their own powers not for the general country or the people of it .,</p>",
"id": "4196012501",
"createdAt": "2018-11-15T10:27:03",
"author": {
"username": "mnaid-90ecce8d5dad4396f681182cb470872c",
"about": "",
"name": "wanderer in eire",
"disable3rdPartyTrackers": true,
"isPowerContributor": false,
"joinedAt": "2017-05-12T20:20:43",
"profileUrl": "https://disqus.com/by/mnaid-90ecce8d5dad4396f681182cb470872c/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "251694793",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-90ecce8d5dad4396f681182cb470872c.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-90ecce8d5dad4396f681182cb470872c.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-90ecce8d5dad4396f681182cb470872c.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": null,
"isApproved": true,
"isFlagged": false,
"raw_message": "Should be no deal end off.\nNobody could possibly be the winner so it's simple leave and that's it .\nTheir will always be wannabes who think they can do better in it for only their own powers not for the general country or the people of it .,",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
},
{
"editableUntil": "2018-11-22T10:26:42",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>Damned if she does, damned if she doesn't. All for a cause she does not believe in.<br>She will go down in history whatever happens. <br>The question is: who better to lead the country at such an important juncture??<br>Answers on a postcard!</p>",
"id": "4196012237",
"createdAt": "2018-11-15T10:26:42",
"author": {
"username": "mnaid-42ba513c42a0fd6558aa44b1de658140",
"about": "",
"name": "chaffwolf",
"disable3rdPartyTrackers": true,
"isPowerContributor": false,
"joinedAt": "2017-12-20T16:45:10",
"profileUrl": "https://disqus.com/by/mnaid-42ba513c42a0fd6558aa44b1de658140/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "274657487",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-42ba513c42a0fd6558aa44b1de658140.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": null,
"isApproved": true,
"isFlagged": false,
"raw_message": "Damned if she does, damned if she doesn't. All for a cause she does not believe in.\nShe will go down in history whatever happens. \nThe question is: who better to lead the country at such an important juncture??\nAnswers on a postcard!",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
},
{
"editableUntil": "2018-11-22T09:50:32",
"dislikes": 0,
"numReports": 0,
"likes": 0,
"message": "<p>Theresa May is using The Eagles Hotel California lyrics as the inspiration for her Brexit plan.</p><p>You can check out any time you like, but you can never leave.</p>",
"id": "4195981074",
"createdAt": "2018-11-15T09:50:32",
"author": {
"username": "mnaid-e82a88d937e60267fd2c866b01131ada",
"about": "",
"name": "Olly the cat",
"disable3rdPartyTrackers": false,
"isPowerContributor": false,
"joinedAt": "2017-05-03T10:27:23",
"profileUrl": "https://disqus.com/by/mnaid-e82a88d937e60267fd2c866b01131ada/",
"url": "",
"location": "",
"isPrivate": false,
"signedUrl": "",
"isPrimary": true,
"isAnonymous": false,
"id": "250727584",
"avatar": {
"small": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-e82a88d937e60267fd2c866b01131ada.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar32.png"
},
"isCustom": false,
"permalink": "https://disqus.com/api/users/avatars/mnaid-e82a88d937e60267fd2c866b01131ada.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png",
"large": {
"permalink": "https://disqus.com/api/users/avatars/mnaid-e82a88d937e60267fd2c866b01131ada.jpg",
"cache": "//a.disquscdn.com/1541535443/images/noavatar92.png"
}
}
},
"media": [],
"isSpam": false,
"isDeletedByAuthor": false,
"isDeleted": false,
"parent": null,
"isApproved": true,
"isFlagged": false,
"raw_message": "Theresa May is using The Eagles Hotel California lyrics as the inspiration for her Brexit plan.\n\nYou can check out any time you like, but you can never leave.",
"isHighlighted": false,
"canVote": false,
"thread": "7046384220",
"forum": "expressandstar",
"points": 0,
"moderationLabels": [],
"isEdited": false,
"sb": false
}
]
}
SQL Statement:
CREATE TABLE cursor(
code DOUBLE NOT NULL,
hasNext VARCHAR(50) NOT NULL,
next VARCHAR(50) NOT NULL,
hasPrev VARCHAR(50) NOT NULL,
id VARCHAR(50) NOT NULL,
more VARCHAR(50) NOT NULL,
PRIMARY KEY (hasNext),
FOREIGN KEY (code) REFERENCES dbjson(code)
)
CREATE TABLE small(
isCustom VARCHAR(50) NOT NULL,
permalink VARCHAR(100) NOT NULL,
cache VARCHAR(100) NOT NULL,
PRIMARY KEY (permalink),
FOREIGN KEY (username) REFERENCES avatar(isCustom)
)
CREATE TABLE moderationLabels(
editableUntil VARCHAR(50) NOT NULL,
FOREIGN KEY (code) REFERENCES response(editableUntil)
)
CREATE TABLE large(
isCustom VARCHAR(50) NOT NULL,
permalink VARCHAR(100) NOT NULL,
cache VARCHAR(100) NOT NULL,
PRIMARY KEY (permalink),
FOREIGN KEY (username) REFERENCES avatar(isCustom)
)
CREATE TABLE response(
code DOUBLE NOT NULL,
editableUntil VARCHAR(50) NOT NULL,
dislikes DOUBLE NOT NULL,
numReports DOUBLE NOT NULL,
likes DOUBLE NOT NULL,
message VARCHAR(200) NOT NULL,
id VARCHAR(50) NOT NULL,
createdAt VARCHAR(50) NOT NULL,
isSpam VARCHAR(50) NOT NULL,
isDeletedByAuthor VARCHAR(50) NOT NULL,
isDeleted VARCHAR(50) NOT NULL,
isApproved VARCHAR(50) NOT NULL,
isFlagged VARCHAR(50) NOT NULL,
raw_message VARCHAR(200) NOT NULL,
isHighlighted VARCHAR(50) NOT NULL,
canVote VARCHAR(50) NOT NULL,
thread VARCHAR(50) NOT NULL,
forum VARCHAR(50) NOT NULL,
points DOUBLE NOT NULL,
isEdited VARCHAR(50) NOT NULL,
sb VARCHAR(50) NOT NULL,
PRIMARY KEY (editableUntil),
FOREIGN KEY (code) REFERENCES dbjson(code)
)
CREATE TABLE author(
editableUntil VARCHAR(50) NOT NULL,
username VARCHAR(50) NOT NULL,
about VARCHAR(50) NOT NULL,
name VARCHAR(50) NOT NULL,
disable3rdPartyTrackers VARCHAR(50) NOT NULL,
isPowerContributor VARCHAR(50) NOT NULL,
joinedAt VARCHAR(50) NOT NULL,
profileUrl VARCHAR(100) NOT NULL,
url VARCHAR(50) NOT NULL,
location VARCHAR(50) NOT NULL,
isPrivate VARCHAR(50) NOT NULL,
signedUrl VARCHAR(50) NOT NULL,
isPrimary VARCHAR(50) NOT NULL,
isAnonymous VARCHAR(50) NOT NULL,
id DOUBLE NOT NULL,
PRIMARY KEY (username),
FOREIGN KEY (code) REFERENCES response(editableUntil)
)
CREATE TABLE avatar(
username VARCHAR(50) NOT NULL,
isCustom VARCHAR(50) NOT NULL,
permalink VARCHAR(100) NOT NULL,
cache VARCHAR(100) NOT NULL,
PRIMARY KEY (isCustom),
FOREIGN KEY (editableUntil) REFERENCES author(username)
)
CREATE TABLE media(
editableUntil VARCHAR(50) NOT NULL,
FOREIGN KEY (code) REFERENCES response(editableUntil)
)
CREATE TABLE dbjson(
code DOUBLE NOT NULL,
PRIMARY KEY (code))
When you define foreign keys, you must define the parent table before you can define a child table that references it. Your tables are defined in an order such that several tables references their parent before the parent is created.
Next problem: cursor is a reserved keyword in MySQL. You must delimit it with back-ticks like this:
CREATE TABLE `cursor`(
...
Next problem: Several tables declare a foreign key on a column that doesn't exist in the table. For example, author has:
FOREIGN KEY (code) REFERENCES response(editableUntil)
But the author table has no column called code. The column must exist in the table before you can declare a foreign key on it. The same problem occurs in tables avatar, small, moderationLabels, large, and media.

accessing elements of json in terminal

I have a number of large json files that I need to be able to read quickly in the terminal. I am interested accessing attributes in the last element of each json, which, for example, might look like this:
},
"source": "Twitter for Android",
"text": "RT #kosaqsi_tweets: Ah ah..!!!",
"truncated": false,
"user": {
"contributors_enabled": false,
"created_at": "Tue May 06 04:48:07 +0000 2014",
"default_profile": true,
"default_profile_image": false,
"description": "",
"entities": {
"description": {
"urls": []
}
},
"favourites_count": 2147,
"follow_request_sent": false,
"followers_count": 72,
"following": false,
"friends_count": 207,
"geo_enabled": true,
"has_extended_profile": false,
"id": 2479274491,
"id_str": "2479274491",
"is_translation_enabled": false,
"is_translator": false,
"lang": "en",
"listed_count": 1,
"location": "Singapore",
"name": "karthikeyan vedalam",
"notifications": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_tile": false,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/2479274491/1453298552",
"profile_image_url": "http://pbs.twimg.com/profile_images/748055063625605120/rByPUFsn_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/748055063625605120/rByPUFsn_normal.jpg",
"profile_link_color": "0084B4",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "k84362172",
"statuses_count": 1521,
"time_zone": null,
"url": null,
"utc_offset": null,
"verified": false
}
}
]
What would be the proper command in terminal to access the last element of the json file and to see, for example, the value of attribute "geo_enabled" ?
The jq command may be your friend.
At a pinch:
jq .user.geo_enabled
It'll be a slightly longer path, given your JSON structure. Probably something like:
jq .[0].parent.user.geo_enabled
(Where 'parent' is whatever is 'above' your user key).