The Movie Database Support

Hello,

I'm trying desperately to display json code in python3. How to convert the variable 'data' in json, to not have a 'print (data)' with a big block of text?

cordially

3 replies (on page 1 of 1)

Jump to last post

Hi there,

I am not familiar with Python so I won't be able to help much. Unless someone who is familiar with it happens to see this post you probably won't get much help here. For coding specific issues, I recommend heading over to a site like Stack Overflow who is a better source for help.

Ok, thank you for answering me. Do not understand how JSON works or have a lot of results. I did a program, without any pretension. I post the other if we have the same problem.


print("type data = "+str(type(data)) )
chaine = str(data.decode('utf8')) 
comptTab=0
ch2=''
ii=0
while ii < len(chaine):
    if (chaine[ii]==','):
        if (chaine[ii+1] == '\"' ):
            ch2+=",\n"
            ch2+=("\t"*comptTab)

    elif (chaine[ii] == '{' ):
        ch2+="\n"
        ch2+=("\t"*comptTab)
        ch2+="{\n"
        comptTab+=1;
        ch2+=("\t"*comptTab)

    elif (chaine[ii]== '}'):
        ch2+="\n"
        comptTab-=1;
        ch2+=("\t"*comptTab)
        ch2+="}"
        ch2+=("\t"*comptTab)

    else:
        if( chaine[ii] == '\\'): # supprime les \\ et les d\
            if( chaine[ii+1] != '\\'):
                chaine[:-1] 
            else:
                ii = ii +1
        else:
            ch2+=chaine[ii]

    ii = ii +1

print(ch2)

Not sure if I quite get what you're going for either. Load data into json then it's a Python3 dict data structure. Can access data chunks by the keys then.

json_message = json.loads(data)
print(data['stuff'])

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Login