IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [F] JSON parse (sub)structure
Victor Kostas
post Oct 21 2014, 07:28
Post #1


Member


Group: Full Members
Posts: 189
Joined: 2-March 08
From: Belgium
Member No.: 6578
Mp3tag Version: 2.80c



JSON web scripts missing functionality.
Trying to find out how to parse a substructure. Not possible.
E.g. "life": {"begin": 1980, "end": 2000}
However if the structure would be a single-element array then no issue :-)
"life": [{"begin": 1980, "end": 2000}]
Florian. Help!!!!

Edit: JSON is new so we understand the missing functionality.
How to access json tag from another branch?
Real example. JSON returns one structure with various header info like: current page, total pages, found items, etc.

Now I need to display current page and total pages in the release row.
%Page% | %Pages% | %items% | %preview%
Now the "fun" begins.
1. It is not possible to select elements of a structure. Let's say this will be available/fixed soon.
2. I am parsing a sibling of this structure, i.e. Release array. How can I access the elements of the siblings of current parent array?

I am stuck now...

This post has been edited by Victor Kostas: Oct 27 2014, 00:37
Go to the top of the page
 
+Quote Post
Florian
post Dec 11 2014, 21:03
Post #2


Developer


Group: Admin
Posts: 8106
Joined: 12-December 01
From: Germany, Dresden
Member No.: 203
Mp3tag Version: 2.85a



Hi Victor,

can you point me to an example API where you experience those problems?

Kind regards
Florian


--------------------
♫ If you like using Mp3tag please donate to support further development.

Go to the top of the page
 
+Quote Post
Victor Kostas
post Dec 11 2014, 23:20
Post #3


Member


Group: Full Members
Posts: 189
Joined: 2-March 08
From: Belgium
Member No.: 6578
Mp3tag Version: 2.80c



QUOTE (Florian @ Dec 11 2014, 21:03) *
Hi Victor,

can you point me to an example API where you experience those problems?

Kind regards
Florian

Hi Florian,

1. You can try this musicbrainz example: search artist.

Trying to extract life-span begin/end values and area (country) name.
CODE
    "life-span": {
        "ended": true,
        "begin": "1977",
        "end": "1995"
    },

    "area": {
        "disambiguation": "",
        "iso_3166_3_codes": [],
        "sort-name": "United Kingdom",
        "name": "United Kingdom",
        "id": "8a754a16-0027-3a29-b6d7-2b40ea0481ed",
        "iso_3166_2_codes": [],
        "iso_3166_1_codes": ["GB"]
    },


2. Adopting official mp3tag discogs.src.
Search by text "Sultans of Swing".

CODE
    "pagination": {
        "per_page": 50,
        "pages": 2,
        "page": 1,
        "urls": {
            "last": "http://api.discogs.com/database/search?release_title=Sultans+Of+Swing&per_page=50&type=release&page=2",
            "next": "http://api.discogs.com/database/search?release_title=Sultans+Of+Swing&per_page=50&type=release&page=2"
        },
        "items": 84
    },
    "results": [{

I want to "access" node "pagination" and its children for each "result" element.

Please let me know if you need additional info.
Kind regards, Victor
Go to the top of the page
 
+Quote Post
Florian
post Dec 13 2014, 14:00
Post #4


Developer


Group: Admin
Posts: 8106
Joined: 12-December 01
From: Germany, Dresden
Member No.: 203
Mp3tag Version: 2.85a



Hi Victor,

as already discussed via PM, the new version Mp3tag v2.66 now provides dedicated functions to select complex JSON objects.

Kind regards
Florian


--------------------
♫ If you like using Mp3tag please donate to support further development.

Go to the top of the page
 
+Quote Post
Victor Kostas
post Dec 13 2014, 18:03
Post #5


Member


Group: Full Members
Posts: 189
Joined: 2-March 08
From: Belgium
Member No.: 6578
Mp3tag Version: 2.80c



QUOTE (Florian @ Dec 13 2014, 14:00) *
Hi Victor,

as already discussed via PM, the new version Mp3tag v2.66 now provides dedicated functions to select complex JSON objects.

Kind regards
Florian

Hi Florian,

Thank you for enhancing JSON functionality. I believe JSON will be involved soon in majority of WS scripts.

1. I confirm new command json_select_object works very well except one small exception: Complex object does not exist. I apologize for not testing in depth the beta version.
I tried ifnot "" to not execute nested json_select without luck.

2. You correctly pointed to store "pagination" element in a temp tag (outputto "tmp") and then provide it to each result element (sayoutput "tmp"). That works perfectly for [ParserScriptAlbum]=... section but not for [ParserScriptIndex]=... one. Maybe I am wrong but tag commands are irrelevant to Index section.

Could you fix those small issues in the next release(s) please or I am missing some commands?

Kind regards,
Victor
Go to the top of the page
 
+Quote Post
Victor Kostas
post Aug 31 2016, 21:31
Post #6


Member


Group: Full Members
Posts: 189
Joined: 2-March 08
From: Belgium
Member No.: 6578
Mp3tag Version: 2.80c



It would be nice if reported bugs (json functionality) are fixed in less time.
It is almost 2 years now without any feedback.
There is no way to know json_select_object found the json object or not. Script is useless in big part of the cases.
Try attached script with different artists (Peter Gabriel, Dire Straits, etc). Pay attention to country name column which is set to artist name in many cases.
Attached File(s)
Attached File  MusicBrainz__json__Artist.src ( 2.64K ) Number of downloads: 77
 
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 24th November 2017 - 10:08