I'm attempting to use Google Sheets to make an audio library that would translate nicely into json (via CSV or some kind of live feed), but I haven't got clue on how to make sub columns that I'll later on use as tags (genre, lyrics theme etc).
Here's the correct json output I want to get from my spreadsheet:
{
"Songs": [
{
"Title": "Bed of Roses",
"Artist": "Bon Jovi",
"Metadata": {
"LyricsTheme": [
"Love",
"Romantic"
],
"Genre": [
"Hard rock",
"Ballad"
]
}
},
{
"Title": "Blue Monday",
"Artist": "New Order",
"Metadata": {
"LyricsTheme": [
"A",
"B",
"C"
],
"Genre": [
"Synthpop",
"Postpunk",
"New wave"
]
}
}
]
}
And here is what I've tried so far with Google Sheets (but that's nowhere near how I want it to be):
Any help would be greatly appreciated.
You'll need to have all of your field names in the first row, and you create the nesting with slashes like this:
This will give you:
[
{
"Title": "Bed of Roses",
"Artist": "Bon Jovi",
"Metadata": {
"LyricsTheme": "Love, Romantic",
"Genre": "Hard Rock, Ballad"
}
},
{
"Title": "Blue Monday",
"Artist": "New Order",
"Metadata": {
"LyricsTheme": "Dogs, Cats, Birds",
"Genre": "Synthpop, Postpunk, New wave"
}
}
]
Finally, in the utility that you use to convert the CSV to JSON, You need to find the output setting that gives you a Top Level Property Name, or something similar.
I used convertcsv.com and it is in the output section.
That will give you:
{
"Songs": [
{
"Title": "Bed of Roses",
"Artist": "Bon Jovi",
"Metadata": {
"LyricsTheme": "Love, Romantic",
"Genre": "Hard Rock, Ballad"
}
},
{
"Title": "Blue Monday",
"Artist": "New Order",
"Metadata": {
"LyricsTheme": "Dogs, Cats, Birds",
"Genre": "Synthpop, Postpunk, New wave"
}
}
]
}
Related
I know I am close on this, the error messages are getting nicer. Currently, I can call a similar call to update the seller's email no issue via Postman currently, working on updating the amount and associated objects. Something in my request format is off.
Is my breakdown section in the correct location? The amount_breakdown documentation looks like it is on same level as value and currency_code, so does it need to move into that section.
Here's my request JSON via Postman:
[
{
"op": "replace",
"path": "/purchase_units/#reference_id=='default'/amount",
"value": {
"currency_code": "CAD",
"value": "2",
"amount": {
"currency_code": "CAD",
"value": "2",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "2"
},
"tax_total": {
"value": "0",
"currency_code": "CAD"
}
}
},
"items": [
{
"name": "First Product Name",
"description": "Optional descriptive text..",
"unit_amount": {
"currency_code": "CAD",
"value": "2"
},
"tax": {
"value": "0",
"currency_code": "CAD"
},
"quantity": "1"
}
]
}
}
]
RESPONSE:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"field": "/purchase_units/#reference_id=='default'/amount/breakdown/item_total",
"location": "body",
"issue": "ITEM_TOTAL_REQUIRED",
"description": "If item details are specified (items.unit_amount and items.quantity) corresponding amount.breakdown.item_total is required."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "acecd3643c994",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ITEM_TOTAL_REQUIRED",
"rel": "information_link",
"method": "GET"
}
]
}
Thanks for any help!
Different variations of objects.
I can get the other PATCH operation working no issue but it is much simpler in object structure
There should be no amount key under the /amount path, and the items array does not belong at that /amount path either.
We thought of a system like which is get meta data and data from backend, and use with these datas UI will render.
Some advantages for us:
Business-independent UI components.
Easy adaptation to channel-based business growth.
Example:
[
{
"popup": {
"title": "All Orders",
"row": [
{
"title": "An Order",
"image": {
"position": "LEFT",
"source": "my.jpg"
}
}
]
}
},
{
"orderDetail": {
"orderNumber": "test",
"orderDate": "test",
"platform": null,
"paymentType": "test"
}
}
]
Have you any suggestion for this, is that a good idea, what are the advantages and disadvantages according to you ?
Are there any tools you can recommend for this function?
The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "#home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
Since you are asking for a gem, you might try iteraptor I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name" on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.
I am working with a Harp project, using Jade templates. I have my _data.json populated with content and I'm having trouble accessing it the way I thought I could. Given this JSON structure:
{
"mountain-residence": {
"slug": "mountain-residence",
"title": "Mountain Residence",
"lead": "A southeast facing home...",
"thumb": "exterior/entry",
"sections": [
{
"exterior": {
"slug": "exterior",
"title": "Exterior Photos",
"lead": "Embracing an entry...",
"thumb": "terrace",
"photos": [
{
"slug": "southeast",
"alt": "Mountain Room Overlook",
"caption": "Porch, deck and spa terrace"
},
{
"slug": "terrace",
"alt": "Southeast Terrace",
"caption": "Spa deck and landscape terrace"
},
{
"slug": "entry",
"alt": "Entry Courtyard",
"caption": "Entry court and pergola"
},
{
"slug": "porch",
"alt": "Entry Porch",
"caption": "Timber entry shelter"
}
]
}
},
{
"interior": {
"slug": "interior",
"title": "Interior Photos",
"lead": "The interior spaces...",
"thumb": "mountain-room2",
"photos": [
{
"slug": "mountain-room2",
"caption": "Entry opening to the Mountain Room"
},
{
"slug": "dining",
"caption": "Dining Room into Mountain Room"
},
{
"slug": "cellar1",
"caption": "Wine Cellar and Tasting Room"
},
{
"slug": "den",
"caption": "Den and Family Hearth"
}
]
}
},
{
"design-sketches": {
"slug": "design-sketches",
"title": "Design Sketches",
"lead": "A careful site...",
"thumb": "shower",
"photos": [
{
"slug": "schematic",
"caption": "Exterior Elevation Study"
},
{
"slug": "elevation",
"caption": "Elevation Color Studies"
},
{
"slug": "shower",
"caption": "Outdoor stone shower"
}
]
}
}
]
}
}
I cannot figure out how to access a named object within an array, like mountain-residence.sections.exterior.title ("Exterior Photos"). Trying mountain-residence.sections['exterior'].title doesn't work either. I can access the same property with mountain-residence.sections[0].title, and my JSON seems to be valid, but I need to call the object with its name... Is there a way to do this?
For example, "mountain-residence" populates a page, and my general idea was to have each object in "sections" populate its own sub-page, which is why I want to be able to call it up by name through my JSON.
As stated in the comments, sections is an array, so only the index notation will work. If you want to get it by the name of the section, it needs to be an object either natively, or else transformed into an object by preprocessing code you write.
I guess this is a big ask. Using PHP I grab this Facebook Graph API json feed json feed link
{
"data": [
{
"id": "10369058551_10150645263758552",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "This week's Land Rover photo of the week is by Rodrigo Beja. Don't forget to submit your best photos each week to get featured.",
"link": "http://www.facebook.com/photo.php?fbid=10150645263678552&set=a.443106273551.221975.10369058551&type=1",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/10150645263758552"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "photo",
"object_id": "10150645263678552",
"created_time": "2012-02-03T17:19:03+0000",
"updated_time": "2012-02-03T22:32:28+0000",
"likes": {
"data": [
{
"name": "Mandy Elder",
"id": "100000250758731"
}
],
"count": 85
},
"comments": {
"data": [
{
"id": "10369058551_10150645263758552_6835532",
"from": {
"name": "John Sharp",
"id": "652940638"
},
"message": "This photo was used as part of the g4 challenge publicity photo pack around 2005-6 \nI remember because at the time I used it as a profile pic on msn \n\nAwesome photo - sums it up perfectly - I love it!!",
"created_time": "2012-02-03T21:39:48+0000"
},
{
"id": "10369058551_10150645263758552_6835852",
"from": {
"name": "Kathryn Piddington",
"id": "777370532"
},
"message": "Mud is good for the soul :)",
"created_time": "2012-02-03T22:32:28+0000"
}
],
"count": 14
}
},
{
"id": "10369058551_355476307803889",
"from": {
"name": "Land Rover",
"category": "Cars",
"id": "10369058551"
},
"message": "Click below to watch the new Range Rover Sport advert and catch up on the latest Land Rover and Range Rover news in this week\u2019s round-up. ",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQAx7xz602rfhyIn&w=90&h=90&url=http\u00253A\u00252F\u00252Fblog.landrover.com\u00252Fwp-content\u00252Fuploads\u00252F12my_rrs_044_LowRes.jpg",
"link": "http://blog.landrover.com/vehicles/the-land-rover-and-range-rover-weekly-19-3578.html#axzz1lKthI4F1",
"name": "The Land Rover and Range Rover Weekly 19 | Land Rover Blog",
"caption": "blog.landrover.com",
"description": "In this week\u2019s round-up of all things Land Rover and Range Rover, the new Range Rover Sport advert, Which? figures reveal the running costs of the Range Rover Evoque in comparison with competitors and a history of Land Rover narrated by Ranulph Fiennes.",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
},
{
"name": "Like",
"link": "http://www.facebook.com/10369058551/posts/355476307803889"
}
],
"privacy": {
"description": "United Kingdom",
"value": "CUSTOM"
},
"type": "link",
"created_time": "2012-02-03T16:44:42+0000",
"updated_time": "2012-02-03T16:44:42+0000",
"likes": {
"data": [
{
"name": "Steve Nesbitt",
"id": "533982936"
}
],
"count": 10
},
"comments": {
"count": 0
}
},
{
"id": "10369058551_10150642499593552",
I'd like to the top level items to a mysql table, then each sub level to anaother table keeping a key / link between each table and then any sub level of a sublevel and linking this too. Is this possible?
I have got as far as this:-
$page = file_get_contents($url);
$json_output = json_decode($page, true);
I can't figure out how to loot hrough each row and add teh data to a Mysql table.
Thanks for your help in advance
Jonathan
Try to loop it as array then make sql query. Each array you put a unique key (for top level item). So, you can use your top level key to sub level foreign key..