you are opening it twice.
<script runat="server" language="Ampscript>
is the same as %%[
See tag based syntax.
You should write your script like this:
<script runat="server" language="Ampscript">
var @Country, @Preheader, @SubjectLine, @Text1, @Text2, @langRowsCount, @LanguageLookup
SET @Country = PersonMailingCountryCode
SET @LanguageLookup = LookupRows('Translation Table - Email 2', 'Country', @Country)
SET @langRowsCount = RowCount(@LanguageLookup)
IF @langRowsCount>1 THEN
SET @langRow = Row(@LanguageLookup, 1)
SET @SubjectLine = Field(@langRow, "SubjectLine")
SET @Preheader = Field(@langRow, "PreHeader")
SET @Text1 = Field(@langRow, "Text1")
SET @Text2 = Field(@langRow, "Text2")
ELSE
SET @SubjectLine = 'X'
SET @Preheader = 'X'
SET @Text1 = 'X'
SET @Text1 = 'X'
ENDIF
</script>
<h3 style="font-family : arial,helvetica,sans-serif; font-size : 20px; color : #808080; line-height : 1; font-weight : bold; font-style : normal; ">%%=v(@Text1)=%%</h3>
%%=v(@Text2)=%%
I'm not sure what you are trying to achieve here. Note that GTL will loop through all JSON objects in an array, just like an AMPscript process loop does. Your objects in the array don't look quite right. However, if you modify your code to read:
%%[
var @Json
set @Json = '{
"Customers":[
{
"CustomerID":1657,
"CompanyName":"AMO Food Market",
"Industry":"Retail",
"ContactName":"Anne Mollin",
"ContactTitle":"Marketing Manager",
"Email":"calin.bostan@osf-global.com",
"FullAddress":{
"Address":"2732 Daver Str.",
"City":"Bandie",
"Region":"OR",
"PostalCode":"94215"
}
},
{
"CustomerID":1658,
"CompanyName":"Folimi Tires",
"Industry":"Cars",
"ContactName":"Adrian Moods",
"ContactTitle":"Sales Representative",
"Email":"adrian.moods@folimitires.com",
"FullAddress":{
"Address":"City Mall 100 Main St.",
"City":"Dondie",
"Region":"OR",
"PostalCode":"93210"
}
}
]
}'
]%%
{{.datasource JSONVar type=variable maxRows = 20}}
{{.data}}
{"target" : "@Json"}
{{/data}}
{{.datasource Customers type=nested maxRows = 20}}
{{.data}}
{ "target" : "JsonVar.Customers" }
{{/data}}
<br>JsonCustomer.CompanyName: {{CompanyName}}
<br>JsonCustomer.CustomerID: {{[CustomerID.-CustomerID]}}
<br>JsonCustomer.Industry: {{Industry}}
<br>JsonCustomer.ContactName: {{ContactName}}
<br>JsonCustomer.ContactTitle: {{ContactTitle}}
<br>JsonCustomer.Email: {{Email}}
{{.datasource JsonFullAddress type=nested maxRows = 20}}
{{.data}}
{ "target" : "Customers.FullAddress" }
{{/data}}
<br>JsonFullAddress.Address: {{Address}}
<br>JsonFullAddress.City: {{City}}
<br>JsonFullAddress.Region: {{Region}}
<br>JsonFullAddress.PostalCode: {{PostalCode}}
%%[
var @ContactName, @index, @FirstName, @LastName
set @contactName = TreatAsContent('{{ContactName}}')
set @index = IndexOf(@ContactName,' ')
set @FirstName = Substring(@ContactName,1,@index)
set @LastName = Substring(@ContactName,@index,Length(@ContactName))
]%%
<br>Hello %%=v(@FirstName)=%% %%=v(@LastName)=%%.
<hr />
{{/datasource}}
{{/datasource}}
{{/datasource}}
...Then this will loop through all objects in your array and display them as:
JsonCustomer.CompanyName: AMO Food Market
JsonCustomer.CustomerID:
JsonCustomer.Industry: Retail
JsonCustomer.ContactName: Anne Mollin
JsonCustomer.ContactTitle: Marketing Manager
JsonCustomer.Email: calin.bostan@osf-global.com
JsonFullAddress.Address: 2732 Daver Str.
JsonFullAddress.City: Bandie
JsonFullAddress.Region: OR
JsonFullAddress.PostalCode: 94215
Hello Anne Mollin.
----------------------------------------------------
JsonCustomer.CompanyName: Folimi Tires
JsonCustomer.CustomerID:
JsonCustomer.Industry: Cars
JsonCustomer.ContactName: Adrian Moods
JsonCustomer.ContactTitle: Sales Representative
JsonCustomer.Email: adrian.moods@folimitires.com
JsonFullAddress.Address: City Mall 100 Main St.
JsonFullAddress.City: Dondie
JsonFullAddress.Region: OR
JsonFullAddress.PostalCode: 93210
Hello Adrian Moods.
Best Answer
You need the VAR keyword: