问:
extract the last updated timestamp from outlook item
I am trying to find out the last recieved email in each outlook folder. for some reason, i can print it but cannot assign it to variable.

the set dat =obj.LastModificationTime is throwing exception. how can i fix it?

```<code>   Private Sub ProcessFolder(folder As MAPIFolder)

Dim folder2 As MAPIFolder
Dim obj As Object
Dim size As Double

Dim dat As Object
Set dat = Empty
If Not folder.Items Is Nothing Then
    For Each obj In folder.Items

        size = size + obj.size
        If TypeName(obj) = "MailItem" Then
       Debug.Print obj.LastModificationTime
      Set dat = obj.LastModificationTime
       End If

    Next
End If
 ' Create The Object
'Set FSO = CreateObject("Scripting.FileSystemObject")
' How To Write To A File

Debug.Print Now() & "," & folder.Name & "," & folder.Items.Count & "," & size & "," & folder.FolderPath & "," & dat
Set dat = Empty

'File.Write folder.Name & "," & folder.Items.Count & "," & size & "," & folder.FolderPath

For Each folder2 In folder.Folders
    ProcessFolder folder2
Next
'File.Close
End Sub

Sub FolderSize()

    'Needs reference to MS Outlook Object Library

   'Needs reference to MS Outlook Object Library

    Dim objOutlook As Outlook.Application
    Dim objNamespace As Outlook.NameSpace
    Dim objSourceFolder As Outlook.MAPIFolder
    Dim objDestFolder As Outlook.MAPIFolder
    Dim InboxMsg As Object
    Dim Inbox As Outlook.folder
    Dim SystemEmails As String

     Dim filter As String
       Dim olParentFolder As Outlook.MAPIFolder
    Dim olFolderA As Outlook.MAPIFolder
    Dim olFolderB As Outlook.MAPIFolder

    Set objOutlook = Application
    Set objNamespace = objOutlook.GetNamespace("MAPI") '

    Set olParentFolder = objNamespace.GetDefaultFolder(olFolderInbox)

    For Each olFolderA In olParentFolder.Folders
       ' Debug.Print olFolderA.FolderPath, olFolderA.Items.Count, olFolderA.Folders.Count

        ProcessFolder olFolderA

    Next

End Sub
</code>```

答: LastModificationTime is a scalar property (DateTime in this case), not an object. "Set" is only required in VB/VBA/VBS for the objects.

Body:
I am trying to find out the last recieved email in each outlook folder. for some reason, i can print it but cannot assign it to variable.

the set dat =obj.LastModificationTime is throwing exception. how can i fix it?

   Private Sub ProcessFolder(folder As MAPIFolder)

Dim folder2 As MAPIFolder
Dim obj As Object
Dim size As Double

Dim dat As Object
Set dat = Empty
If Not folder.Items Is Nothing Then
    For Each obj In folder.Items

        size = size + obj.size
        If TypeName(obj) = "MailItem" Then
       Debug.Print obj.LastModificationTime
      Set dat = obj.LastModificationTime
       End If

    Next
End If
 ' Create The Object
'Set FSO = CreateObject("Scripting.FileSystemObject")
' How To Write To A File

Debug.Print Now() & "," & folder.Name & "," & folder.Items.Count & "," & size & "," & folder.FolderPath & "," & dat
Set dat = Empty

'File.Write folder.Name & "," & folder.Items.Count & "," & size & "," & folder.FolderPath

For Each folder2 In folder.Folders
    ProcessFolder folder2
Next
'File.Close
End Sub

Sub FolderSize()

    'Needs reference to MS Outlook Object Library

   'Needs reference to MS Outlook Object Library

    Dim objOutlook As Outlook.Application
    Dim objNamespace As Outlook.NameSpace
    Dim objSourceFolder As Outlook.MAPIFolder
    Dim objDestFolder As Outlook.MAPIFolder
    Dim InboxMsg As Object
    Dim Inbox As Outlook.folder
    Dim SystemEmails As String

     Dim filter As String
       Dim olParentFolder As Outlook.MAPIFolder
    Dim olFolderA As Outlook.MAPIFolder
    Dim olFolderB As Outlook.MAPIFolder

    Set objOutlook = Application
    Set objNamespace = objOutlook.GetNamespace("MAPI") '

    Set olParentFolder = objNamespace.GetDefaultFolder(olFolderInbox)

    For Each olFolderA In olParentFolder.Folders
       ' Debug.Print olFolderA.FolderPath, olFolderA.Items.Count, olFolderA.Folders.Count

        ProcessFolder olFolderA

    Next

End Sub


来源: stackexchange

问:
C++ does not use the desired constructor
So there seems to be some problem with the solution to Problem 9-2 in the book "Object-Oriented Programming in C++, 4th edition" by Robert Lafore. So the problem is that if I would like to create a Pstring object with a statement like Pstring = "This is a string", the Pstring constructor will only call the constructor with no arguments in the String class, instead of the second one with uses one char[] argument. Does anyone know what causes this kind of problem, and a fix to this? Thanks!

```<code>#include <iostream>
#include <cstring>
using namespace std;
////////////////////////////////////////////////////////////////
class String                      //base class
{
protected:                     //Note: can't be private
    enum {
        SZ = 80
    };           //size of all String objects
    char str[SZ];               //holds a C-string
public:
    String()                    //constructor 0, no args
    {
        str[0] = '\0';
    }
    String(char s[])          //constructor 1, one arg
            {
        strcpy(str, s);
    }      //  convert string to String
    void display() const        //display the String
    {
        cout << str;
    }
    operator char*()            //conversion function
    {
        return str;
    }          //convert String to C-string
};
////////////////////////////////////////////////////////////////
class Pstring: public String     //derived class
{
public:
    Pstring(char s[]);        //constructor
};
//--------------------------------------------------------------
Pstring::Pstring(char s[])      //constructor for Pstring
        {
    if (strlen(s) > SZ - 1)           //if too long,
            {
        for (int j = 0; j < SZ - 1; j++) {  //copy the first SZ-1
            str[j] = s[j];           //characters "by hand"
            str[j] = '\0';
        }           //add the null character
    } else
        //not too long,
        String(s);                  //so construct normally
}
////////////////////////////////////////////////////////////////
int main() {                                        //define String
    String s1 = "This is a string"; // This works great
    s1.display();
    Pstring s2 = "This is a string"; // *** Here, nothing will be assigned to s2****
    s2.display();                    // *** Nothing will be printed here***
    return 0;
}
</code>```

答:
In a function parameter, a T[] (where T is char in your case) is really a T*.

In C++, a string literal is a const char[N] fixed array, which decays into a const char* pointer to the 1st element. But you don't have any constructors that accept either of those types as a parameter. A const char* can't be given to a char*. You need to add const to your constructors:

String(const char s[])

Pstring(const char s[])

Also, calling String(s) in the body of the Pstring constructor does not initialize the Pstring object using the base class String constructor, like you are expecting. It instead constructs a temporary String object that goes out of scope immediately. The Pstring object is not affected by that.

The only place that a base class constructor can be called by a derived constructor is in the member initialization list. In your case, there is no such call, so the compiler implicitly calls the base class default (0-param) constructor before entering the body of the derived constructor. Which doesn't help you, since you want the base class to initialize the str buffer with data.

One way you can do that is add another constructor to String that takes a user-defined length as input, and then call that from the Pstring constructor, eg:

```<code>String(const char s[], size_t len)
{
    len = std::min(len, SZ-1);
    memcpy(str, s, len);
    str[len] = '\0';
}

Pstring::Pstring(const char s[])
    : String(s, strlen(s))
{
}
</code>```

Note that your 1-param String constructor has a buffer overflow waiting to happen, since the user can directly construct a String object with input that is greater than SZ characters in length. The String constructor should use strncpy() instead of strcpy():

```<code>String(const char s[])
{
    strncpy(str, s, SZ);
    str[SZ-1] = '\0'; // in case s is >= SZ chars
}
</code>```

Which then makes the 1-param Pstring constructor redundant - especially since it is not handling the null terminator correctly to begin with, as the assignment of the terminator needs to be outside of the for loop, eg:

```<code>Pstring::Pstring(const char s[])
{
    if (strlen(s) >= SZ)
    {
        for (int j = 0; j < SZ - 1; j++) {
            str[j] = s[j];
        }
        // alternatively: memcpy(str, sz, SZ-1);
        str[SZ-1] = '\0'; // <-- moved here
    }
    else
        strcpy(str, s);
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
So there seems to be some problem with the solution to Problem 9-2 in the book "Object-Oriented Programming in C++, 4th edition" by Robert Lafore. So the problem is that if I would like to create a Pstring object with a statement like Pstring = "This is a string", the Pstring constructor will only call the constructor with no arguments in the String class, instead of the second one with uses one char[] argument. Does anyone know what causes this kind of problem, and a fix to this? Thanks!

#include <iostream>
#include <cstring>
using namespace std;
////////////////////////////////////////////////////////////////
class String                      //base class
{
protected:                     //Note: can't be private
    enum {
        SZ = 80
    };           //size of all String objects
    char str[SZ];               //holds a C-string
public:
    String()                    //constructor 0, no args
    {
        str[0] = '\0';
    }
    String(char s[])          //constructor 1, one arg
            {
        strcpy(str, s);
    }      //  convert string to String
    void display() const        //display the String
    {
        cout << str;
    }
    operator char*()            //conversion function
    {
        return str;
    }          //convert String to C-string
};
////////////////////////////////////////////////////////////////
class Pstring: public String     //derived class
{
public:
    Pstring(char s[]);        //constructor
};
//--------------------------------------------------------------
Pstring::Pstring(char s[])      //constructor for Pstring
        {
    if (strlen(s) > SZ - 1)           //if too long,
            {
        for (int j = 0; j < SZ - 1; j++) {  //copy the first SZ-1
            str[j] = s[j];           //characters "by hand"
            str[j] = '\0';
        }           //add the null character
    } else
        //not too long,
        String(s);                  //so construct normally
}
////////////////////////////////////////////////////////////////
int main() {                                        //define String
    String s1 = "This is a string"; // This works great
    s1.display();
    Pstring s2 = "This is a string"; // *** Here, nothing will be assigned to s2****
    s2.display();                    // *** Nothing will be printed here***
    return 0;
}

Body:
In a function parameter, a T[] (where T is char in your case) is really a T*.

In C++, a string literal is a const char[N] fixed array, which decays into a const char* pointer to the 1st element. But you don't have any constructors that accept either of those types as a parameter. A const char* can't be given to a char*. You need to add const to your constructors:

String(const char s[])

Pstring(const char s[])

Also, calling String(s) in the body of the Pstring constructor does not initialize the Pstring object using the base class String constructor, like you are expecting. It instead constructs a temporary String object that goes out of scope immediately. The Pstring object is not affected by that.

The only place that a base class constructor can be called by a derived constructor is in the member initialization list. In your case, there is no such call, so the compiler implicitly calls the base class default (0-param) constructor before entering the body of the derived constructor. Which doesn't help you, since you want the base class to initialize the str buffer with data.

One way you can do that is add another constructor to String that takes a user-defined length as input, and then call that from the Pstring constructor, eg:

String(const char s[], size_t len)
{
    len = std::min(len, SZ-1);
    memcpy(str, s, len);
    str[len] = '\0';
}

Pstring::Pstring(const char s[])
    : String(s, strlen(s))
{
}

Note that your 1-param String constructor has a buffer overflow waiting to happen, since the user can directly construct a String object with input that is greater than SZ characters in length. The String constructor should use strncpy() instead of strcpy():

String(const char s[])
{
    strncpy(str, s, SZ);
    str[SZ-1] = '\0'; // in case s is >= SZ chars
}

Which then makes the 1-param Pstring constructor redundant - especially since it is not handling the null terminator correctly to begin with, as the assignment of the terminator needs to be outside of the for loop, eg:

Pstring::Pstring(const char s[])
{
    if (strlen(s) >= SZ)
    {
        for (int j = 0; j < SZ - 1; j++) {
            str[j] = s[j];
        }
        // alternatively: memcpy(str, sz, SZ-1);
        str[SZ-1] = '\0'; // <-- moved here
    }
    else
        strcpy(str, s);
}


问:
Editor only view in XCode
I am using swiftUI to write a new app. Every-time I open a new file the Canvas opens up.
I want the default view to be "Only Editor" and I can open the canvas whenever I want to manually.

Is there a way to change the default?

答:
Yes you can select "show editor only" via Xcode, this will always open the Editor, check the  screenshot

Adjust Editor Option ---- show editor only

or Select any SwiftUI file then press Command + Enter(Return key) this will select the show editor only option.

Title: Editor only view in XCode


问:
Pagnation in Python (Beautifulsoup)
I'm new to Python and whilst I have managed to scrape the first page I'm stuck as to how to move through the pagnation. Here's my code so far for the first page:</p>

```<code>import requests
import csv
from bs4 import BeautifulSoup
page = requests.get("http://books.toscrape.com/")
soup = BeautifulSoup(page.content, 'html.parser')
books = soup.find("section")
book_list = books.find_all(class_="product_pod")

csvfile = csv.writer(open('books.csv', 'w', newline=''))
csvfile.writerow(['Title', 'Price', 'Stock', 'Link'])

for book in book_list:
    price = book.find(class_="price_color").get_text()
    title = book.select_one('a img')['alt']
    stock = book.find('p',attrs={"class":"instock availability"}).get_text().strip()
    link = "http://books.toscrape.com/" + book.find('a')['href']
    csvfile.writerow([title, price, stock, link])
</code>```

答:
One solution is to "hardcode" number of pages (in this case, 50). Or you could get next page "dynamically". That means search for "Next" button on current page, if exists, get the link and continue scraping. If "Next" button doesn't exist, stop running.

For example:

```<code>import csv
import requests
from bs4 import BeautifulSoup

page = requests.get("http://books.toscrape.com/")

with open('books.csv', 'w') as f_out:   # books.csv
    csvfile = csv.writer(f_out)
    csvfile.writerow(['Title', 'Price', 'Stock', 'Link'])

    current_page = 1
    current_url = "http://books.toscrape.com/"

    while True:
        print('Processing page {}...'.format(current_page))

        soup = BeautifulSoup(page.content, 'html.parser')
        books = soup.find("section")
        book_list = books.find_all(class_="product_pod")

        for book in book_list:
            price = book.find(class_="price_color").get_text()
            title = book.select_one('a img')['alt']
            stock = book.find('p',attrs={"class":"instock availability"}).get_text().strip()
            link = "http://books.toscrape.com/" + book.find('a')['href']
            csvfile.writerow([title, price, stock, link])

        # is there "Next" button
        next_link = soup.select_one('li.next > a')

        if not next_link:
            # no, we're on last page, exit
            break

        # yes, continue:
        current_url = current_url.rsplit('/', maxsplit=1)[0] + '/' + next_link['href']
        page = requests.get(current_url)
        current_page += 1
</code>```

Produces:

Title: Pagnation in Python (Beautifulsoup)

Body:
I'm new to Python and whilst I have managed to scrape the first page I'm stuck as to how to move through the pagnation. Here's my code so far for the first page:

import requests
import csv
from bs4 import BeautifulSoup
page = requests.get("http://books.toscrape.com/")
soup = BeautifulSoup(page.content, 'html.parser')
books = soup.find("section")
book_list = books.find_all(class_="product_pod")

csvfile = csv.writer(open('books.csv', 'w', newline=''))
csvfile.writerow(['Title', 'Price', 'Stock', 'Link'])

for book in book_list:
    price = book.find(class_="price_color").get_text()
    title = book.select_one('a img')['alt']
    stock = book.find('p',attrs={"class":"instock availability"}).get_text().strip()
    link = "http://books.toscrape.com/" + book.find('a')['href']
    csvfile.writerow([title, price, stock, link])

Body:
One solution is to "hardcode" number of pages (in this case, 50). Or you could get next page "dynamically". That means search for "Next" button on current page, if exists, get the link and continue scraping. If "Next" button doesn't exist, stop running.

For example:

import csv
import requests
from bs4 import BeautifulSoup

page = requests.get("http://books.toscrape.com/")

with open('books.csv', 'w') as f_out:   # books.csv
    csvfile = csv.writer(f_out)
    csvfile.writerow(['Title', 'Price', 'Stock', 'Link'])

    current_page = 1
    current_url = "http://books.toscrape.com/"

    while True:
        print('Processing page {}...'.format(current_page))

        soup = BeautifulSoup(page.content, 'html.parser')
        books = soup.find("section")
        book_list = books.find_all(class_="product_pod")

        for book in book_list:
            price = book.find(class_="price_color").get_text()
            title = book.select_one('a img')['alt']
            stock = book.find('p',attrs={"class":"instock availability"}).get_text().strip()
            link = "http://books.toscrape.com/" + book.find('a')['href']
            csvfile.writerow([title, price, stock, link])

        # is there "Next" button
        next_link = soup.select_one('li.next > a')

        if not next_link:
            # no, we're on last page, exit
            break

        # yes, continue:
        current_url = current_url.rsplit('/', maxsplit=1)[0] + '/' + next_link['href']
        page = requests.get(current_url)
        current_page += 1

Produces:


问:
How to work with Rows/Columns from CSV files?
I have about 10 columns of data in a CSV file that I want to get statistics on using python. I am currently using the import csv module to open the file and read the contents. But I also want to look at 2 particular columns to compare data and get a percentage of accuracy based on the data.
Although I can open the file and parse through the rows I cannot figure out for example how to compare:

Row[i] Column[8] with Row[i] Column[10]

My pseudo code would be something like this:

category = Row[i] Column[8]

label = Row[i] Column[10]

```<code>if(category!=label):
   difference+=1
   totalChecked+=1
else:
  correct+=1
  totalChecked+=1
</code>```

The only thing I am able to do is to read the entire row. But I want to get the exact Row and Column of my 2 variables  category and label and compare them.

How do I work with specific row/columns for an entire excel sheet?

答:
convert both to pandas dataframes and compare similarly as this example. Whatever dataset your working on using the Pandas module, alongside any other necessary relevant modules, and transforming the data into lists and dataframes, would be first step to working with it imo.

I've taken the liberty and time/ effort to delve into this myself as it will be useful to me going forward. Columns don't have to have the same lengths at all in his example, so that's good. I've tested the below code (Python 3.8) and it works successfully.

With only a slight adaptations can be used for your specific data columns, objects and purposes.

```<code>import pandas as pd
A = pd.read_csv(r'C:\Users\User\Documents\query_sequences.csv') #dropped the S fom _sequences
B = pd.read_csv(r'C:\Users\User\Documents\Sequence_reference.csv')

print(A.columns)
print(B.columns)

my_unknown_id = A['Unknown_sample_no'].tolist() #Unknown_sample_no
my_unknown_seq = A['Unknown_sample_seq'].tolist() #Unknown_sample_seq

Reference_Species1 = B['Reference_sequences_ID'].tolist()
Reference_Sequences1 = B['Reference_Sequences'].tolist() #it was Reference_sequences

Ref_dict = dict(zip(Reference_Species1, Reference_Sequences1)) #it was Reference_sequences
Unknown_dict = dict(zip(my_unknown_id, my_unknown_seq))

print(Ref_dict)
print(Unknown_dict)

Ref_dict = dict(zip(Reference_Species1, Reference_Sequences1))
Unknown_dict = dict(zip(my_unknown_id, my_unknown_seq))

print(Ref_dict)
print(Unknown_dict)

import re
filename = 'seq_match_compare2.csv'
f = open(filename, 'a') #in his eg it was 'w'

headers = 'Query_ID, Query_Seq, Ref_species, Ref_seq, Match, Match start Position\n'
f.write(headers)

for ID, seq in Unknown_dict.items():
    for species, seq1 in Ref_dict.items():
         m = re.search(seq, seq1)
         if m:
              match = m.group()
              pos = m.start() + 1
              f.write(str(ID) + ',' + seq + ',' + species + ',' + seq1 + ',' + match + ',' + str(pos) + '\n')

f.close()
</code>```

And I did it myself too, assuming your columns contained integers, and according to your specifications (As best at the moment I can). Its my first try [Its my first attempt without webscraping, so go easy]. You could use my code below for a benchmark of how to move forward on your question.
Basically it does what you want (give you the skeleton) and does this : "imports csv in python using pandas module, converts to dataframes, works on specific columns only in those df's, make new columns (results), prints results alongside the original data in the terminal, and saves to new csv. It's as as messy as my python is , but it works! personally (& professionally) speaking is a milestone for me and I Will hopefully be working on it at a later date to improve it readability, scope, functionality and abilities [as the days go by (from next weekend).]

```<code># This is work in progress, (although it does work and does a job), and its doing that for you. there are redundant lines of code in it, even the lines not hashed out (because im a self teaching  newbie on my weekends). I was just  finishing up on getting the results printed to a new csv file (done too). You can see how you could convert your columns & rows into lists with pandas dataframes, and start to do calculations with them in Python, and get your results back out to a new CSV. It a start on how you can answer your question going forward
#ITS FOR HER TO DO MUCH MORE & BETTER ON!! BUT IT DOES IN BASIC TERMS WHAT SHE ASKED FOR.

import pandas as pd
from pandas import DataFrame
import csv
import itertools #redundant now'?

A = pd.read_csv(r'C:\Users\User\Documents\book6 category labels.csv')

A["Category"].fillna("empty data - missing value", inplace = True)
#A["Blank1"].fillna("empty data - missing value", inplace = True)
# ...etc

print(A.columns)

MyCat=A['Category'].tolist()
MyLab=A['Label'].tolist()

My_Cats = A['Category1'].tolist()

My_Labs = A['Label1'].tolist()
#Ref_dict0 = zip(My_Labs, My_Cats) #good to compare whole columns as block, Enumerate ZIP 19:06 01/06/2020 FORGET THIS FOR NOW, WAS PART OF A LATTER ATTEMPT TO COMPARE TEXT & MISSED TEXT WITH INTERGER FIELDS. DOESNT EFFECT PROGRAM

Ref_dict = dict(zip(My_Labs, My_Cats))

Compareprep = dict(zip(My_Cats, My_Labs))

Ref_dict = dict(zip(My_Cats, My_Labs))

print(Ref_dict)

import re #this is for string matching & comparison. redundant in my example here but youll need it to compare tables if strings.
#filename = 'CATS&LABS64.csv' # when i got to exporting part, this is redundant now
#csvfile = open(filename, 'a') #when i tried to export results/output it first time - redundant

print("Given Dataframe :\n", A)

A['Lab-Cat_diff'] = A['Category1'].sub(A['Label1'], axis=0)
print("\nDifference of score1 and score2 :\n", A)

#YOU CAN DO OTHER MATCHES, COMPARISONS AND CALCULTAIONS YOURSELF HERE AND ADD THEM TO THE OUTPUT

result = (print("\nDifference of score1 and score2 :\n", A))
result2 = print(A) and print(result)
def result22(result2):
    for aSentence in result2:
        df = pd.DataFrame(result2)
    print(str())
    return df

print(result2)
print(result22) # printing out the function itself 'produces nothing but its name of course

output_df = DataFrame((result2),A)
output_df.to_csv('some_name5523.csv')
</code>```

Yes, i know, its by no means perfect At all, but wanted to give you the heads up about panda's and dataframes for doing what you want moving forward.

Body:
I have about 10 columns of data in a CSV file that I want to get statistics on using python. I am currently using the import csv module to open the file and read the contents. But I also want to look at 2 particular columns to compare data and get a percentage of accuracy based on the data.
Although I can open the file and parse through the rows I cannot figure out for example how to compare:

Row[i] Column[8] with Row[i] Column[10]

My pseudo code would be something like this:

category = Row[i] Column[8]

label = Row[i] Column[10]

if(category!=label):
   difference+=1
   totalChecked+=1
else:
  correct+=1
  totalChecked+=1

The only thing I am able to do is to read the entire row. But I want to get the exact Row and Column of my 2 variables  category and label and compare them.

How do I work with specific row/columns for an entire excel sheet?

Body:
convert both to pandas dataframes and compare similarly as this example. Whatever dataset your working on using the Pandas module, alongside any other necessary relevant modules, and transforming the data into lists and dataframes, would be first step to working with it imo.

I've taken the liberty and time/ effort to delve into this myself as it will be useful to me going forward. Columns don't have to have the same lengths at all in his example, so that's good. I've tested the below code (Python 3.8) and it works successfully.

With only a slight adaptations can be used for your specific data columns, objects and purposes.

import pandas as pd
A = pd.read_csv(r'C:\Users\User\Documents\query_sequences.csv') #dropped the S fom _sequences
B = pd.read_csv(r'C:\Users\User\Documents\Sequence_reference.csv')

print(A.columns)
print(B.columns)

my_unknown_id = A['Unknown_sample_no'].tolist() #Unknown_sample_no
my_unknown_seq = A['Unknown_sample_seq'].tolist() #Unknown_sample_seq

Reference_Species1 = B['Reference_sequences_ID'].tolist()
Reference_Sequences1 = B['Reference_Sequences'].tolist() #it was Reference_sequences

Ref_dict = dict(zip(Reference_Species1, Reference_Sequences1)) #it was Reference_sequences
Unknown_dict = dict(zip(my_unknown_id, my_unknown_seq))

print(Ref_dict)
print(Unknown_dict)

Ref_dict = dict(zip(Reference_Species1, Reference_Sequences1))
Unknown_dict = dict(zip(my_unknown_id, my_unknown_seq))

print(Ref_dict)
print(Unknown_dict)

import re
filename = 'seq_match_compare2.csv'
f = open(filename, 'a') #in his eg it was 'w'

headers = 'Query_ID, Query_Seq, Ref_species, Ref_seq, Match, Match start Position\n'
f.write(headers)

for ID, seq in Unknown_dict.items():
    for species, seq1 in Ref_dict.items():
         m = re.search(seq, seq1)
         if m:
              match = m.group()
              pos = m.start() + 1
              f.write(str(ID) + ',' + seq + ',' + species + ',' + seq1 + ',' + match + ',' + str(pos) + '\n')

f.close()

And I did it myself too, assuming your columns contained integers, and according to your specifications (As best at the moment I can). Its my first try [Its my first attempt without webscraping, so go easy]. You could use my code below for a benchmark of how to move forward on your question.
Basically it does what you want (give you the skeleton) and does this : "imports csv in python using pandas module, converts to dataframes, works on specific columns only in those df's, make new columns (results), prints results alongside the original data in the terminal, and saves to new csv. It's as as messy as my python is , but it works! personally (& professionally) speaking is a milestone for me and I Will hopefully be working on it at a later date to improve it readability, scope, functionality and abilities [as the days go by (from next weekend).]

# This is work in progress, (although it does work and does a job), and its doing that for you. there are redundant lines of code in it, even the lines not hashed out (because im a self teaching  newbie on my weekends). I was just  finishing up on getting the results printed to a new csv file (done too). You can see how you could convert your columns & rows into lists with pandas dataframes, and start to do calculations with them in Python, and get your results back out to a new CSV. It a start on how you can answer your question going forward
#ITS FOR HER TO DO MUCH MORE & BETTER ON!! BUT IT DOES IN BASIC TERMS WHAT SHE ASKED FOR.

import pandas as pd
from pandas import DataFrame
import csv
import itertools #redundant now'?

A = pd.read_csv(r'C:\Users\User\Documents\book6 category labels.csv')

A["Category"].fillna("empty data - missing value", inplace = True)
#A["Blank1"].fillna("empty data - missing value", inplace = True)
# ...etc

print(A.columns)

MyCat=A['Category'].tolist()
MyLab=A['Label'].tolist()

My_Cats = A['Category1'].tolist()

My_Labs = A['Label1'].tolist()
#Ref_dict0 = zip(My_Labs, My_Cats) #good to compare whole columns as block, Enumerate ZIP 19:06 01/06/2020 FORGET THIS FOR NOW, WAS PART OF A LATTER ATTEMPT TO COMPARE TEXT & MISSED TEXT WITH INTERGER FIELDS. DOESNT EFFECT PROGRAM

Ref_dict = dict(zip(My_Labs, My_Cats))

Compareprep = dict(zip(My_Cats, My_Labs))

Ref_dict = dict(zip(My_Cats, My_Labs))

print(Ref_dict)

import re #this is for string matching & comparison. redundant in my example here but youll need it to compare tables if strings.
#filename = 'CATS&LABS64.csv' # when i got to exporting part, this is redundant now
#csvfile = open(filename, 'a') #when i tried to export results/output it first time - redundant

print("Given Dataframe :\n", A)

A['Lab-Cat_diff'] = A['Category1'].sub(A['Label1'], axis=0)
print("\nDifference of score1 and score2 :\n", A)

#YOU CAN DO OTHER MATCHES, COMPARISONS AND CALCULTAIONS YOURSELF HERE AND ADD THEM TO THE OUTPUT

result = (print("\nDifference of score1 and score2 :\n", A))
result2 = print(A) and print(result)
def result22(result2):
    for aSentence in result2:
        df = pd.DataFrame(result2)
    print(str())
    return df

print(result2)
print(result22) # printing out the function itself 'produces nothing but its name of course

output_df = DataFrame((result2),A)
output_df.to_csv('some_name5523.csv')

Yes, i know, its by no means perfect At all, but wanted to give you the heads up about panda's and dataframes for doing what you want moving forward.


问:
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 7770 path $.films[8].images.poster
I am receiving the error
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 7770 path $.films[8].images.poster
when I try to return a list of films. The application was working fine till yesterday when I came to test it, it now throws this error. I hadn't changed any of the code since only the API credentials since I went over the limit.

MainActivity

```<code>public class MainActivity extends AppCompatActivity {
    private TextView textViewResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textViewResult = findViewById(R.id.text_view_result);

        OkHttpClient.Builder client = new OkHttpClient.Builder();
        client.addInterceptor(new Interceptor() {
            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {
                Request request = chain.request()
                        .newBuilder()
                        .addHeader("api-version", "v200")
                        .addHeader("Authorization", "*******************************")
                        .addHeader("client", "***************")
                        .addHeader("x-api-key", "********************************")
                        .addHeader("device-datetime", "2018-09-14T08:30:17.360Z")
                        .addHeader("territory", "UK")
                        .addHeader("Geolocation", "52.4814;-1.8998")
                        .build();
                Log.d("djd", request.toString());
                return chain.proceed(request);
            }
        });
        Retrofit retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("https://api-gate2.movieglu.com/")
                .client(client.build())
                .build();

        MovieGluApi movieGluApi = retrofit.create(MovieGluApi.class);
        Call<Film> filmCall = movieGluApi.getFilmNames();
        filmCall.enqueue(new Callback<Film>() {
            @Override
            public void onResponse(Call<Film> call,Response<Film> response) {
                if (!response.isSuccessful()){
                    textViewResult.setText("Code: " + response.code());
                    Log.d("dfkjf", response.toString());
                    return;
                }

                assert response.body() != null;
                List<Film> films = response.body().getFilms();
                Log.d("dfkjf", response.toString());

                for (Film film : films){
                    String content = "";
                    content += "Film ID: " + film.getFilmId() +"\n";
                    content += "IMDB ID: " + film.getImdbId() +"\n";
                    content += "Film Name: " + film.getFilmName() +"\n\n";
                    Log.d("Film name", film.toString());
                    textViewResult.append(content);
                }
            }
            @Override
            public void onFailure(Call<Film> call, Throwable t) {
                textViewResult.setText(t.getMessage());
                Log.d("What is films", t.getMessage());
            }
        });
    }
}
</code>```

API service

```<code>    @GET("filmsNowShowing/")
    Call<Film> getFilmNames();

    @GET("cinemasNearby/")
    Call <Cinema> getNearbyCinema();
}
</code>```

Film Model

```<code>public class Film {

    @SerializedName("films")
    @Expose
    List<Film> films;

    public List<Film> getFilms() {
        Log.d("What is films", films.toString());
        return films;
    }

    @SerializedName("film_id")
    @Expose
    private Integer filmId;
    @SerializedName("imdb_id")
    @Expose
    private Integer imdbId;
    @SerializedName("film_name")
    @Expose
    private String filmName;
    @SerializedName("release_dates")
    @Expose
    private List<ReleaseDate> releaseDates = null;
    @SerializedName("age_rating")
    @Expose
    private List<AgeRating> ageRating = null;
    @SerializedName("film_trailer")
    @Expose
    private Object filmTrailer;
    @SerializedName("synopsis_long")
    @Expose
    private String synopsisLong;
    @SerializedName("images")
    @Expose
    private Images images;

    public Integer getFilmId() {
        return filmId;
    }

    public void setFilmId(Integer filmId) {
        this.filmId = filmId;
    }

    public Integer getImdbId() {
        return imdbId;
    }

    public void setImdbId(Integer imdbId) {
        this.imdbId = imdbId;
    }

    public String getFilmName() {
        return filmName;
    }

    public void setFilmName(String filmName) {
        this.filmName = filmName;
    }

    public List<ReleaseDate> getReleaseDates() {
        return releaseDates;
    }

    public void setReleaseDates(List<ReleaseDate> releaseDates) {
        this.releaseDates = releaseDates;
    }

    public List<AgeRating> getAgeRating() {
        return ageRating;
    }

    public void setAgeRating(List<AgeRating> ageRating) {
        this.ageRating = ageRating;
    }

    public Object getFilmTrailer() {
        return filmTrailer;
    }

    public void setFilmTrailer(Object filmTrailer) {
        this.filmTrailer = filmTrailer;
    }

    public String getSynopsisLong() {
        return synopsisLong;
    }

    public void setSynopsisLong(String synopsisLong) {
        this.synopsisLong = synopsisLong;
    }

    public Images getImages() {
        return images;
    }

    public void setImages(Images images) {
        this.images = images;
    }

}
</code>```

JSON Response - Postman

```<code>{
    "films": [
        {
            "film_id": 3139,
            "imdb_id": 112641,
            "film_name": "Casino",
            "release_dates": [
                {
                    "release_date": "1995-11-28",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "18 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/18.png",
                    "age_advisory": "strong violence"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Robert DeNiro, Sharon Stone and Joe Pesci star in director Martin Scorsese's riveting look at how blind ambition, white-hot passion and 24-karat greed toppled an empire. Las Vegas 1973 is the setting for this fact-based story about the Mob's multi-million dollar casino operation - where fortunes and lives were made and lost with a roll of the dice.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3139/003139h1.jpg",
                            "width": 199,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 7257,
            "imdb_id": 80455,
            "film_name": "The Blues Brothers",
            "release_dates": [
                {
                    "release_date": "2009-07-24",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "15 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/15.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/7257_high.mp4",
            "synopsis_long": "Jake and Elwood Blues endeavor to raise $5,000 for their childhood parrish by putting their old band back together uand taking their show on the road. While touring, they manage to wreak havoc on the entire city of Chicago and much of the midwest.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/7257/GBR_007257h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    },
                    "2": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/7257/AUS_007257h0.jpg",
                            "width": 164,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 12486,
            "imdb_id": 94336,
            "film_name": "Withnail & I",
            "release_dates": [
                {
                    "release_date": "2007-09-07",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "15 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/15.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/12486/GBR_012486h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 279925,
            "imdb_id": 7549996,
            "film_name": "Judy",
            "release_dates": [
                {
                    "release_date": "2019-10-04",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "12A ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/12a.png",
                    "age_advisory": "scenes of drug misuse, infrequent strong language"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/279925_uk_high_V3.mp4",
            "synopsis_long": "Winter 1968 and showbiz legend Judy Garland arrives in Swinging London to perform a five-week sold-out run at The Talk of the Town. It is 30 years since she shot to global stardom in The Wizard of Oz, but if her voice has weakened, its dramatic intensity has only grown. As she prepares for the show, battles with management, charms musicians and reminisces with friends and adoring fans, her wit and warmth shine through. Even her dreams of love seem undimmed as she embarks on a whirlwind romance with Mickey Deans, her soon-to-be fifth husband. Featuring some of her best-known songs, the film celebrates the voice, the capacity for love, and the sheer pizzazz of \"the world's greatest entertainer.\"",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/279925/GBR_279925h0.jpg",
                            "width": 202,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/279925/279925h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 80849,
            "imdb_id": 77631,
            "film_name": "Grease Sing-A-Long",
            "release_dates": [
                {
                    "release_date": "2010-07-13",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Rydell High's most famous graduating class is going back to school. A newly restored print brings the highest-grossing musical of all time, \"Grease\" (1978), to the big screen as a sing-along. Join Danny and Sandy with your own crew of T-Birds and Pink Ladies for a carnival ride back to those amazing summer nights!",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/80849/080849h1.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/80849/080849h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 281047,
            "imdb_id": 7715070,
            "film_name": "Horrible Histories: The Movie",
            "release_dates": [
                {
                    "release_date": "2019-07-26",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": "mild comic violence, injury detail, rude humour, language"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/281047_uk_high.mp4",
            "synopsis_long": "Friends, Romans, Celts lend us your ears. The all-conquering Romans rule the civilised world and that includes the stain that is Britain. While the young Emperor Nero must battle his scheming mother Agrippina for ultimate power, Celt queen Boudicca gathers an army in Britain to repel the rotten Romans. Mixed up in this battle for liberation are the teenage Atti, a reluctant Roman soldier, and Orla, a young Celt with dreams of becoming a warrior like Boudicca. Will they fall on opposite sides or forge a friendship in the chaos of Celtic-inspired rebellion?",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/281047/GBR_281047h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/281047/281047h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 2129,
            "imdb_id": 45152,
            "film_name": "Singin' in the Rain",
            "release_dates": [
                {
                    "release_date": "2019-10-18",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "U ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/u.png",
                    "age_advisory": "very mild comic violence"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/2129_high.mp4",
            "synopsis_long": "Gene Kelly, Debbie Reynolds and Donald O'Connor star in Singin' in the Rain, one of the greatest and most successful musicals ever filmed - filled with memorable songs, lavish routines and Kelly's fabulous song-and-dance number performed in the rain.\n\nSet during the advent of \"talkies,\" Don Lockwood  has risen to stardom during Hollywood's silent-movie era - paired with the beautiful, jealous and dumb Lina Lamont. And when Lockwood becomes attracted to young studio singer Kathy Selden, Lamont has her fired.\n\nBut with the introduction of talking pictures, Lockwood finds his career in jeopardy after audiences laugh when they hear Lamont speak in her shrill voice for the first time... until the studio decides to use Selden to dub her voice.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/GBR_002129h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    },
                    "2": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/AUS_002129h0.jpg",
                            "width": 220,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/002129h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 6548,
            "imdb_id": 38669,
            "film_name": "The Killers (1946)",
            "release_dates": [
                {
                    "release_date": "1946-09-16",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/6548/GBR_006548h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 4705,
            "imdb_id": 96928,
            "film_name": "Bill & Ted's Excellent Adventure",
            "release_dates": [
                {
                    "release_date": "1989-08-25",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": "Contains mild language and violence"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Bill Preston and Ted Logan are two totally excellent dudes facing one most heinous history exam. With the help of Rufus an ultra-cool messenger in a time traveling phone booth, the triumphant two-some bag a bevy of historical heavy weights like the \"Bodacious Philosopher Socrates, \"One Very Excellent Barbarian\" Genghis Khan, the \"Short Dead Dude\" Napoleon and Noah's Wife Joan of Arc to stage the most hysterical high school project ever. History's about to be rewritten by two guys who can't even spell.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/4705/GBR_004705h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 3855,
            "imdb_id": 93191,
            "film_name": "Wings of Desire",
            "release_dates": [
                {
                    "release_date": "1990-10-01",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "12 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/12.png",
                    "age_advisory": "Contains one use of strong language"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "\"Wings of Desire\" is one of cinema's loveliest city symphonies. Bruno Ganz is Damiel, an angel perched atop buildings high over Berlin who can hear the thoughts fears, hopes, dreams of all the people living below. But when he falls in love with a beautiful trapeze artist, he is willing to give up his immortality and come back to earth to be with her. Made not long before the fall of the Berlin wall, this stunning tapestry of sounds and images, shot in black and white and color by the legendary Henri Alekan, is movie poetry. And it forever made the name Wim Wenders synonymous with film art.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3855/GBR_003855h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3855/003855h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        }
    ],
    "status": {
        "count": 10,
        "state": "OK",
        "method": "filmsNowShowing",
        "message": null,
        "request_method": "GET",
        "version": "WALS_2v200",
        "territory": "UK",
        "device_datetime_sent": "2020-05-17T08:30:17.360Z",
        "device_datetime_used": "2020-05-17 08:30:17"
    }
}
</code>```

答:
use these pogo classes and run your code</p>

```<code>==================================
package ;
public class Release_dates
{
    private DateTime release_date;

    private String notes;

    public void setRelease_date(DateTime release_date){
        this.release_date = release_date;
    }
    public DateTime getRelease_date(){
        return this.release_date;
    }
    public void setNotes(String notes){
        this.notes = notes;
    }
    public String getNotes(){
        return this.notes;
    }
}

==================================
package ;
public class Age_rating
{
    private String rating;

    private String age_rating_image;

    private String age_advisory;

    public void setRating(String rating){
        this.rating = rating;
    }
    public String getRating(){
        return this.rating;
    }
    public void setAge_rating_image(String age_rating_image){
        this.age_rating_image = age_rating_image;
    }
    public String getAge_rating_image(){
        return this.age_rating_image;
    }
    public void setAge_advisory(String age_advisory){
        this.age_advisory = age_advisory;
    }
    public String getAge_advisory(){
        return this.age_advisory;
    }
}

==================================
package ;
public class Medium
{
    private String film_image;

    private int width;

    private int height;

    public void setFilm_image(String film_image){
        this.film_image = film_image;
    }
    public String getFilm_image(){
        return this.film_image;
    }
    public void setWidth(int width){
        this.width = width;
    }
    public int getWidth(){
        return this.width;
    }
    public void setHeight(int height){
        this.height = height;
    }
    public int getHeight(){
        return this.height;
    }
}

==================================
package ;
public class 1
{
    private String image_orientation;

    private String region;

    private Medium medium;

    public void setImage_orientation(String image_orientation){
        this.image_orientation = image_orientation;
    }
    public String getImage_orientation(){
        return this.image_orientation;
    }
    public void setRegion(String region){
        this.region = region;
    }
    public String getRegion(){
        return this.region;
    }
    public void setMedium(Medium medium){
        this.medium = medium;
    }
    public Medium getMedium(){
        return this.medium;
    }
}

==================================
package ;
public class Poster
{
    private 1 1;

    public void set1(1 1){
        this.1 = 1;
    }
    public 1 get1(){
        return this.1;
    }
}

==================================
package ;
public class Images
{
    private Poster poster;

    public void setPoster(Poster poster){
        this.poster = poster;
    }
    public Poster getPoster(){
        return this.poster;
    }
}

==================================
package ;
import java.util.ArrayList;
import java.util.List;
public class Films
{
    private int film_id;

    private int imdb_id;

    private String film_name;

    private List<Release_dates> release_dates;

    private List<Age_rating> age_rating;

    private String film_trailer;

    private String synopsis_long;

    private Images images;

    public void setFilm_id(int film_id){
        this.film_id = film_id;
    }
    public int getFilm_id(){
        return this.film_id;
    }
    public void setImdb_id(int imdb_id){
        this.imdb_id = imdb_id;
    }
    public int getImdb_id(){
        return this.imdb_id;
    }
    public void setFilm_name(String film_name){
        this.film_name = film_name;
    }
    public String getFilm_name(){
        return this.film_name;
    }
    public void setRelease_dates(List<Release_dates> release_dates){
        this.release_dates = release_dates;
    }
    public List<Release_dates> getRelease_dates(){
        return this.release_dates;
    }
    public void setAge_rating(List<Age_rating> age_rating){
        this.age_rating = age_rating;
    }
    public List<Age_rating> getAge_rating(){
        return this.age_rating;
    }
    public void setFilm_trailer(String film_trailer){
        this.film_trailer = film_trailer;
    }
    public String getFilm_trailer(){
        return this.film_trailer;
    }
    public void setSynopsis_long(String synopsis_long){
        this.synopsis_long = synopsis_long;
    }
    public String getSynopsis_long(){
        return this.synopsis_long;
    }
    public void setImages(Images images){
        this.images = images;
    }
    public Images getImages(){
        return this.images;
    }
}

==================================
package ;
public class Status
{
    private int count;

    private String state;

    private String method;

    private String message;

    private String request_method;

    private String version;

    private String territory;

    private String device_datetime_sent;

    private DateTime device_datetime_used;

    public void setCount(int count){
        this.count = count;
    }
    public int getCount(){
        return this.count;
    }
    public void setState(String state){
        this.state = state;
    }
    public String getState(){
        return this.state;
    }
    public void setMethod(String method){
        this.method = method;
    }
    public String getMethod(){
        return this.method;
    }
    public void setMessage(String message){
        this.message = message;
    }
    public String getMessage(){
        return this.message;
    }
    public void setRequest_method(String request_method){
        this.request_method = request_method;
    }
    public String getRequest_method(){
        return this.request_method;
    }
    public void setVersion(String version){
        this.version = version;
    }
    public String getVersion(){
        return this.version;
    }
    public void setTerritory(String territory){
        this.territory = territory;
    }
    public String getTerritory(){
        return this.territory;
    }
    public void setDevice_datetime_sent(String device_datetime_sent){
        this.device_datetime_sent = device_datetime_sent;
    }
    public String getDevice_datetime_sent(){
        return this.device_datetime_sent;
    }
    public void setDevice_datetime_used(DateTime device_datetime_used){
        this.device_datetime_used = device_datetime_used;
    }
    public DateTime getDevice_datetime_used(){
        return this.device_datetime_used;
    }
}

==================================
package ;
import java.util.ArrayList;
import java.util.List;
public class Root
{
    private List<Films> films;

    private Status status;

    public void setFilms(List<Films> films){
        this.films = films;
    }
    public List<Films> getFilms(){
        return this.films;
    }
    public void setStatus(Status status){
        this.status = status;
    }
    public Status getStatus(){
        return this.status;
    }
}
</code>```

Body:
I am receiving the error
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 7770 path $.films[8].images.poster
when I try to return a list of films. The application was working fine till yesterday when I came to test it, it now throws this error. I hadn't changed any of the code since only the API credentials since I went over the limit.

MainActivity

public class MainActivity extends AppCompatActivity {
    private TextView textViewResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textViewResult = findViewById(R.id.text_view_result);

        OkHttpClient.Builder client = new OkHttpClient.Builder();
        client.addInterceptor(new Interceptor() {
            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {
                Request request = chain.request()
                        .newBuilder()
                        .addHeader("api-version", "v200")
                        .addHeader("Authorization", "*******************************")
                        .addHeader("client", "***************")
                        .addHeader("x-api-key", "********************************")
                        .addHeader("device-datetime", "2018-09-14T08:30:17.360Z")
                        .addHeader("territory", "UK")
                        .addHeader("Geolocation", "52.4814;-1.8998")
                        .build();
                Log.d("djd", request.toString());
                return chain.proceed(request);
            }
        });
        Retrofit retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .baseUrl("https://api-gate2.movieglu.com/")
                .client(client.build())
                .build();

        MovieGluApi movieGluApi = retrofit.create(MovieGluApi.class);
        Call<Film> filmCall = movieGluApi.getFilmNames();
        filmCall.enqueue(new Callback<Film>() {
            @Override
            public void onResponse(Call<Film> call,Response<Film> response) {
                if (!response.isSuccessful()){
                    textViewResult.setText("Code: " + response.code());
                    Log.d("dfkjf", response.toString());
                    return;
                }

                assert response.body() != null;
                List<Film> films = response.body().getFilms();
                Log.d("dfkjf", response.toString());

                for (Film film : films){
                    String content = "";
                    content += "Film ID: " + film.getFilmId() +"\n";
                    content += "IMDB ID: " + film.getImdbId() +"\n";
                    content += "Film Name: " + film.getFilmName() +"\n\n";
                    Log.d("Film name", film.toString());
                    textViewResult.append(content);
                }
            }
            @Override
            public void onFailure(Call<Film> call, Throwable t) {
                textViewResult.setText(t.getMessage());
                Log.d("What is films", t.getMessage());
            }
        });
    }
}

API service

    @GET("filmsNowShowing/")
    Call<Film> getFilmNames();

    @GET("cinemasNearby/")
    Call <Cinema> getNearbyCinema();
}

Film Model

public class Film {

    @SerializedName("films")
    @Expose
    List<Film> films;

    public List<Film> getFilms() {
        Log.d("What is films", films.toString());
        return films;
    }

    @SerializedName("film_id")
    @Expose
    private Integer filmId;
    @SerializedName("imdb_id")
    @Expose
    private Integer imdbId;
    @SerializedName("film_name")
    @Expose
    private String filmName;
    @SerializedName("release_dates")
    @Expose
    private List<ReleaseDate> releaseDates = null;
    @SerializedName("age_rating")
    @Expose
    private List<AgeRating> ageRating = null;
    @SerializedName("film_trailer")
    @Expose
    private Object filmTrailer;
    @SerializedName("synopsis_long")
    @Expose
    private String synopsisLong;
    @SerializedName("images")
    @Expose
    private Images images;

    public Integer getFilmId() {
        return filmId;
    }

    public void setFilmId(Integer filmId) {
        this.filmId = filmId;
    }

    public Integer getImdbId() {
        return imdbId;
    }

    public void setImdbId(Integer imdbId) {
        this.imdbId = imdbId;
    }

    public String getFilmName() {
        return filmName;
    }

    public void setFilmName(String filmName) {
        this.filmName = filmName;
    }

    public List<ReleaseDate> getReleaseDates() {
        return releaseDates;
    }

    public void setReleaseDates(List<ReleaseDate> releaseDates) {
        this.releaseDates = releaseDates;
    }

    public List<AgeRating> getAgeRating() {
        return ageRating;
    }

    public void setAgeRating(List<AgeRating> ageRating) {
        this.ageRating = ageRating;
    }

    public Object getFilmTrailer() {
        return filmTrailer;
    }

    public void setFilmTrailer(Object filmTrailer) {
        this.filmTrailer = filmTrailer;
    }

    public String getSynopsisLong() {
        return synopsisLong;
    }

    public void setSynopsisLong(String synopsisLong) {
        this.synopsisLong = synopsisLong;
    }

    public Images getImages() {
        return images;
    }

    public void setImages(Images images) {
        this.images = images;
    }

}

JSON Response - Postman

{
    "films": [
        {
            "film_id": 3139,
            "imdb_id": 112641,
            "film_name": "Casino",
            "release_dates": [
                {
                    "release_date": "1995-11-28",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "18 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/18.png",
                    "age_advisory": "strong violence"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Robert DeNiro, Sharon Stone and Joe Pesci star in director Martin Scorsese's riveting look at how blind ambition, white-hot passion and 24-karat greed toppled an empire. Las Vegas 1973 is the setting for this fact-based story about the Mob's multi-million dollar casino operation - where fortunes and lives were made and lost with a roll of the dice.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3139/003139h1.jpg",
                            "width": 199,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 7257,
            "imdb_id": 80455,
            "film_name": "The Blues Brothers",
            "release_dates": [
                {
                    "release_date": "2009-07-24",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "15 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/15.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/7257_high.mp4",
            "synopsis_long": "Jake and Elwood Blues endeavor to raise $5,000 for their childhood parrish by putting their old band back together uand taking their show on the road. While touring, they manage to wreak havoc on the entire city of Chicago and much of the midwest.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/7257/GBR_007257h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    },
                    "2": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/7257/AUS_007257h0.jpg",
                            "width": 164,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 12486,
            "imdb_id": 94336,
            "film_name": "Withnail & I",
            "release_dates": [
                {
                    "release_date": "2007-09-07",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "15 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/15.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/12486/GBR_012486h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 279925,
            "imdb_id": 7549996,
            "film_name": "Judy",
            "release_dates": [
                {
                    "release_date": "2019-10-04",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "12A ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/12a.png",
                    "age_advisory": "scenes of drug misuse, infrequent strong language"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/279925_uk_high_V3.mp4",
            "synopsis_long": "Winter 1968 and showbiz legend Judy Garland arrives in Swinging London to perform a five-week sold-out run at The Talk of the Town. It is 30 years since she shot to global stardom in The Wizard of Oz, but if her voice has weakened, its dramatic intensity has only grown. As she prepares for the show, battles with management, charms musicians and reminisces with friends and adoring fans, her wit and warmth shine through. Even her dreams of love seem undimmed as she embarks on a whirlwind romance with Mickey Deans, her soon-to-be fifth husband. Featuring some of her best-known songs, the film celebrates the voice, the capacity for love, and the sheer pizzazz of \"the world's greatest entertainer.\"",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/279925/GBR_279925h0.jpg",
                            "width": 202,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/279925/279925h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 80849,
            "imdb_id": 77631,
            "film_name": "Grease Sing-A-Long",
            "release_dates": [
                {
                    "release_date": "2010-07-13",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Rydell High's most famous graduating class is going back to school. A newly restored print brings the highest-grossing musical of all time, \"Grease\" (1978), to the big screen as a sing-along. Join Danny and Sandy with your own crew of T-Birds and Pink Ladies for a carnival ride back to those amazing summer nights!",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/80849/080849h1.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/80849/080849h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 281047,
            "imdb_id": 7715070,
            "film_name": "Horrible Histories: The Movie",
            "release_dates": [
                {
                    "release_date": "2019-07-26",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": "mild comic violence, injury detail, rude humour, language"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/281047_uk_high.mp4",
            "synopsis_long": "Friends, Romans, Celts lend us your ears. The all-conquering Romans rule the civilised world and that includes the stain that is Britain. While the young Emperor Nero must battle his scheming mother Agrippina for ultimate power, Celt queen Boudicca gathers an army in Britain to repel the rotten Romans. Mixed up in this battle for liberation are the teenage Atti, a reluctant Roman soldier, and Orla, a young Celt with dreams of becoming a warrior like Boudicca. Will they fall on opposite sides or forge a friendship in the chaos of Celtic-inspired rebellion?",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/281047/GBR_281047h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/281047/281047h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 2129,
            "imdb_id": 45152,
            "film_name": "Singin' in the Rain",
            "release_dates": [
                {
                    "release_date": "2019-10-18",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "U ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/u.png",
                    "age_advisory": "very mild comic violence"
                }
            ],
            "film_trailer": "https://trailer.movieglu.com/2129_high.mp4",
            "synopsis_long": "Gene Kelly, Debbie Reynolds and Donald O'Connor star in Singin' in the Rain, one of the greatest and most successful musicals ever filmed - filled with memorable songs, lavish routines and Kelly's fabulous song-and-dance number performed in the rain.\n\nSet during the advent of \"talkies,\" Don Lockwood  has risen to stardom during Hollywood's silent-movie era - paired with the beautiful, jealous and dumb Lina Lamont. And when Lockwood becomes attracted to young studio singer Kathy Selden, Lamont has her fired.\n\nBut with the introduction of talking pictures, Lockwood finds his career in jeopardy after audiences laugh when they hear Lamont speak in her shrill voice for the first time... until the studio decides to use Selden to dub her voice.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/GBR_002129h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    },
                    "2": {
                        "image_orientation": "portrait",
                        "region": "global",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/AUS_002129h0.jpg",
                            "width": 220,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/2129/002129h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        },
        {
            "film_id": 6548,
            "imdb_id": 38669,
            "film_name": "The Killers (1946)",
            "release_dates": [
                {
                    "release_date": "1946-09-16",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": ""
                }
            ],
            "film_trailer": null,
            "synopsis_long": "",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/6548/GBR_006548h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 4705,
            "imdb_id": 96928,
            "film_name": "Bill & Ted's Excellent Adventure",
            "release_dates": [
                {
                    "release_date": "1989-08-25",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "PG ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/pg.png",
                    "age_advisory": "Contains mild language and violence"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "Bill Preston and Ted Logan are two totally excellent dudes facing one most heinous history exam. With the help of Rufus an ultra-cool messenger in a time traveling phone booth, the triumphant two-some bag a bevy of historical heavy weights like the \"Bodacious Philosopher Socrates, \"One Very Excellent Barbarian\" Genghis Khan, the \"Short Dead Dude\" Napoleon and Noah's Wife Joan of Arc to stage the most hysterical high school project ever. History's about to be rewritten by two guys who can't even spell.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/4705/GBR_004705h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                }
            }
        },
        {
            "film_id": 3855,
            "imdb_id": 93191,
            "film_name": "Wings of Desire",
            "release_dates": [
                {
                    "release_date": "1990-10-01",
                    "notes": "GBR"
                }
            ],
            "age_rating": [
                {
                    "rating": "12 ",
                    "age_rating_image": "https://assets.movieglu.com/age_rating_logos/uk/12.png",
                    "age_advisory": "Contains one use of strong language"
                }
            ],
            "film_trailer": null,
            "synopsis_long": "\"Wings of Desire\" is one of cinema's loveliest city symphonies. Bruno Ganz is Damiel, an angel perched atop buildings high over Berlin who can hear the thoughts fears, hopes, dreams of all the people living below. But when he falls in love with a beautiful trapeze artist, he is willing to give up his immortality and come back to earth to be with her. Made not long before the fall of the Berlin wall, this stunning tapestry of sounds and images, shot in black and white and color by the legendary Henri Alekan, is movie poetry. And it forever made the name Wim Wenders synonymous with film art.",
            "images": {
                "poster": {
                    "1": {
                        "image_orientation": "portrait",
                        "region": "UK",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3855/GBR_003855h0.jpg",
                            "width": 200,
                            "height": 300
                        }
                    }
                },
                "still": {
                    "1": {
                        "image_orientation": "landscape",
                        "medium": {
                            "film_image": "https://image.movieglu.com/3855/003855h2.jpg",
                            "width": 300,
                            "height": 200
                        }
                    }
                }
            }
        }
    ],
    "status": {
        "count": 10,
        "state": "OK",
        "method": "filmsNowShowing",
        "message": null,
        "request_method": "GET",
        "version": "WALS_2v200",
        "territory": "UK",
        "device_datetime_sent": "2020-05-17T08:30:17.360Z",
        "device_datetime_used": "2020-05-17 08:30:17"
    }
}

Body:
use these pogo classes and run your code

==================================
package ;
public class Release_dates
{
    private DateTime release_date;

    private String notes;

    public void setRelease_date(DateTime release_date){
        this.release_date = release_date;
    }
    public DateTime getRelease_date(){
        return this.release_date;
    }
    public void setNotes(String notes){
        this.notes = notes;
    }
    public String getNotes(){
        return this.notes;
    }
}

==================================
package ;
public class Age_rating
{
    private String rating;

    private String age_rating_image;

    private String age_advisory;

    public void setRating(String rating){
        this.rating = rating;
    }
    public String getRating(){
        return this.rating;
    }
    public void setAge_rating_image(String age_rating_image){
        this.age_rating_image = age_rating_image;
    }
    public String getAge_rating_image(){
        return this.age_rating_image;
    }
    public void setAge_advisory(String age_advisory){
        this.age_advisory = age_advisory;
    }
    public String getAge_advisory(){
        return this.age_advisory;
    }
}

==================================
package ;
public class Medium
{
    private String film_image;

    private int width;

    private int height;

    public void setFilm_image(String film_image){
        this.film_image = film_image;
    }
    public String getFilm_image(){
        return this.film_image;
    }
    public void setWidth(int width){
        this.width = width;
    }
    public int getWidth(){
        return this.width;
    }
    public void setHeight(int height){
        this.height = height;
    }
    public int getHeight(){
        return this.height;
    }
}

==================================
package ;
public class 1
{
    private String image_orientation;

    private String region;

    private Medium medium;

    public void setImage_orientation(String image_orientation){
        this.image_orientation = image_orientation;
    }
    public String getImage_orientation(){
        return this.image_orientation;
    }
    public void setRegion(String region){
        this.region = region;
    }
    public String getRegion(){
        return this.region;
    }
    public void setMedium(Medium medium){
        this.medium = medium;
    }
    public Medium getMedium(){
        return this.medium;
    }
}

==================================
package ;
public class Poster
{
    private 1 1;

    public void set1(1 1){
        this.1 = 1;
    }
    public 1 get1(){
        return this.1;
    }
}

==================================
package ;
public class Images
{
    private Poster poster;

    public void setPoster(Poster poster){
        this.poster = poster;
    }
    public Poster getPoster(){
        return this.poster;
    }
}

==================================
package ;
import java.util.ArrayList;
import java.util.List;
public class Films
{
    private int film_id;

    private int imdb_id;

    private String film_name;

    private List<Release_dates> release_dates;

    private List<Age_rating> age_rating;

    private String film_trailer;

    private String synopsis_long;

    private Images images;

    public void setFilm_id(int film_id){
        this.film_id = film_id;
    }
    public int getFilm_id(){
        return this.film_id;
    }
    public void setImdb_id(int imdb_id){
        this.imdb_id = imdb_id;
    }
    public int getImdb_id(){
        return this.imdb_id;
    }
    public void setFilm_name(String film_name){
        this.film_name = film_name;
    }
    public String getFilm_name(){
        return this.film_name;
    }
    public void setRelease_dates(List<Release_dates> release_dates){
        this.release_dates = release_dates;
    }
    public List<Release_dates> getRelease_dates(){
        return this.release_dates;
    }
    public void setAge_rating(List<Age_rating> age_rating){
        this.age_rating = age_rating;
    }
    public List<Age_rating> getAge_rating(){
        return this.age_rating;
    }
    public void setFilm_trailer(String film_trailer){
        this.film_trailer = film_trailer;
    }
    public String getFilm_trailer(){
        return this.film_trailer;
    }
    public void setSynopsis_long(String synopsis_long){
        this.synopsis_long = synopsis_long;
    }
    public String getSynopsis_long(){
        return this.synopsis_long;
    }
    public void setImages(Images images){
        this.images = images;
    }
    public Images getImages(){
        return this.images;
    }
}

==================================
package ;
public class Status
{
    private int count;

    private String state;

    private String method;

    private String message;

    private String request_method;

    private String version;

    private String territory;

    private String device_datetime_sent;

    private DateTime device_datetime_used;

    public void setCount(int count){
        this.count = count;
    }
    public int getCount(){
        return this.count;
    }
    public void setState(String state){
        this.state = state;
    }
    public String getState(){
        return this.state;
    }
    public void setMethod(String method){
        this.method = method;
    }
    public String getMethod(){
        return this.method;
    }
    public void setMessage(String message){
        this.message = message;
    }
    public String getMessage(){
        return this.message;
    }
    public void setRequest_method(String request_method){
        this.request_method = request_method;
    }
    public String getRequest_method(){
        return this.request_method;
    }
    public void setVersion(String version){
        this.version = version;
    }
    public String getVersion(){
        return this.version;
    }
    public void setTerritory(String territory){
        this.territory = territory;
    }
    public String getTerritory(){
        return this.territory;
    }
    public void setDevice_datetime_sent(String device_datetime_sent){
        this.device_datetime_sent = device_datetime_sent;
    }
    public String getDevice_datetime_sent(){
        return this.device_datetime_sent;
    }
    public void setDevice_datetime_used(DateTime device_datetime_used){
        this.device_datetime_used = device_datetime_used;
    }
    public DateTime getDevice_datetime_used(){
        return this.device_datetime_used;
    }
}

==================================
package ;
import java.util.ArrayList;
import java.util.List;
public class Root
{
    private List<Films> films;

    private Status status;

    public void setFilms(List<Films> films){
        this.films = films;
    }
    public List<Films> getFilms(){
        return this.films;
    }
    public void setStatus(Status status){
        this.status = status;
    }
    public Status getStatus(){
        return this.status;
    }
}


问:
React Native - fetch API error: [SyntaxError: JSON Parse error: Unexpected identifier "object"]
Newbie to React Native. I am trying to use FormData to upload image and data using the fetch API following example from Spencer Carli. My back end works fine, when I use postman the image uploads to the database storage without any problem. But when I try to upload image via the mobile device I get

```<code>upload error [SyntaxError: JSON Parse error: Unexpected identifier "Tunnel"]
</code>```

Below is my code

     const createFormData = (photo, body) => {
        const data = new FormData();

        data.append('file', {
            name: photo.fileName,
            type: photo.type,
            uri:
                Platform.OS === 'android' ? photo.uri : photo.uri.replace('file://', ''),
            });

        Object.keys(body).forEach(key => {
          data.append(key, body[key]);
        });

        return data;
      };

    const uploadPhotoHandler = async (photo) => {
        const token = await AsyncStorage.getItem('token');
        fetch('http://ba9737b7.ngrok.io/post', {
            headers: {'Authorization': 'Bearer ' + token},
            method: 'POST',
            body: createFormData(photo, {
                title: 'Golden twisted knots',
                postType: 'hair',
                duration: 45}),
          })
          .then(response => response.json())
          .then(response => {
            console.log('upload succes', response);
            alert('Upload success!');
          })
          .catch(error => {
            console.log('upload error', error);
            alert('Upload failed!');
          });
    };
```

<p>I think the problem is from this line</p>

<pre class="lang-js prettyprint-override"><code>    .then(response => response.json())
</code>```

but I don't know why.

答:
The problem is because you are not getting a JSON response. When you are trying to parse to JSON.
You can solve it checking first the response status code, try this.</p>

```<code>const uploadPhotoHandler = async (photo) => {
        const token = await AsyncStorage.getItem('token');
        fetch('http://ba9737b7.ngrok.io/post', {
            headers: {'Authorization': 'Bearer ' + token},
            method: 'POST',
            body: createFormData(photo, {
                title: 'Golden twisted knots',
                postType: 'hair',
                duration: 45}),
          })
          .then(response => {

            //If the response status code is between 200-299, if so
            if(response.ok) return response.json();

             //if not, throw a error
             throw new Error('Network response was not ok');
          })
          .then(response => {
            console.log('upload succes', response);
            alert('Upload success!');
          })
          .catch(error => {
            console.log('upload error', error);
            alert('Upload failed!');
          });
    };

</code>```

Body:
Newbie to React Native. I am trying to use FormData to upload image and data using the fetch API following example from Spencer Carli. My back end works fine, when I use postman the image uploads to the database storage without any problem. But when I try to upload image via the mobile device I get

upload error [SyntaxError: JSON Parse error: Unexpected identifier "Tunnel"]

Below is my code

     const createFormData = (photo, body) => {
        const data = new FormData();

        data.append('file', {
            name: photo.fileName,
            type: photo.type,
            uri:
                Platform.OS === 'android' ? photo.uri : photo.uri.replace('file://', ''),
            });

        Object.keys(body).forEach(key => {
          data.append(key, body[key]);
        });

        return data;
      };

    const uploadPhotoHandler = async (photo) => {
        const token = await AsyncStorage.getItem('token');
        fetch('http://ba9737b7.ngrok.io/post', {
            headers: {'Authorization': 'Bearer ' + token},
            method: 'POST',
            body: createFormData(photo, {
                title: 'Golden twisted knots',
                postType: 'hair',
                duration: 45}),
          })
          .then(response => response.json())
          .then(response => {
            console.log('upload succes', response);
            alert('Upload success!');
          })
          .catch(error => {
            console.log('upload error', error);
            alert('Upload failed!');
          });
    };

I think the problem is from this line

    .then(response => response.json())

but I don't know why.

Body:
The problem is because you are not getting a JSON response. When you are trying to parse to JSON.
You can solve it checking first the response status code, try this.

const uploadPhotoHandler = async (photo) => {
        const token = await AsyncStorage.getItem('token');
        fetch('http://ba9737b7.ngrok.io/post', {
            headers: {'Authorization': 'Bearer ' + token},
            method: 'POST',
            body: createFormData(photo, {
                title: 'Golden twisted knots',
                postType: 'hair',
                duration: 45}),
          })
          .then(response => {

            //If the response status code is between 200-299, if so
            if(response.ok) return response.json();

             //if not, throw a error
             throw new Error('Network response was not ok');
          })
          .then(response => {
            console.log('upload succes', response);
            alert('Upload success!');
          })
          .catch(error => {
            console.log('upload error', error);
            alert('Upload failed!');
          });
    };