Forum Discussion

xoceunder's avatar
xoceunder
Roku Guru
9 years ago

this error field

Warning occurred while setting a field of an RoSGNode
-- Type mismatch occurred when setting the "category" field of a "ParseEpg" node
   at line 48 of file pkg:/components/ParseEpg/ParseEpg.brs

ParseEpg.brs
Function init()
  m.top.functionName = "go"
  m.top.control = "RUN"
End Function

Function go()

readInternet = createObject("roUrlTransfer")
m.content    = createObject("RoSGNode","ContentNode")

readInternet.setUrl(m.top.uri)
source=readInternet.GetToString()
responseJSON = ParseJSON(source)

    dateNow = CreateObject("roDateTime")
    dateNow = dateNow.asSeconds() - 2000


Category=[]
numofcategories=responseJSON.Count()-1
For c=0 To numofcategories
   Cat={}
Cat.Title=responseJSON[c].category
Cat.Id=responseJSON[c].cve
Category.Push(Cat)
if responseJSON[c].items <> invalid
For x=0 To responseJSON[c].items.Count()-1
itemAA=responseJSON[c].items[x]
'print itemAA.Title
            m.channel = m.content.createChild("ContentNode")
            m.channel.Title = itemAA.Title
            m.channel.streamFormat = itemAA.streamFormat
            m.channel.url = itemAA.StreamUrls
            'm.channel.HDSMALLICONURL = itemAA.HDPosterURL

  For e=0 To responseJSON[c].items[x].epg_now.Count()-1
    epgNowAA=responseJSON[c].items[x].epg_now[e]
program = m.channel.createChild("ContentNode")
                 program.TITLE = epgNowAA.epg_after
                 program.PLAYSTART = dateNow + (e * 2000)
                 'program.PLAYDURATION = "2000"
  Next
Next
end if
Next

m.top.content=m.content 'set top content field
m.top.category=Category 'set top content field
'print Category.Title
End Function




ParseEpg.xml
<?xml version="1.0" encoding="utf-8" ?>
<!--********** Copyright 2015 Roku Corp.  All Rights Reserved. **********-->

<component name="ParseEpg" extends="Task">
<interface>
<field id="uri" type="uri" />
<field id="content" type="node" />
<field id="category" type="assocarray" />
</interface>
<script type="text/brightscript" uri="pkg:/components/ParseEpg/ParseEpg.brs"/>
</component>

2 Replies

  • 24i's avatar
    24i
    Streaming Star
    Hi xoceunder,

    Incase you haven't found the issue yet, it seems like you are trying to assign an Array to an AssociativeArray field.
    You should change:
    <field id="category" type="assocarray" />

    To:
    <field id="category" type="array" />


    Since the 'Category' var is an Array and not an AssociativeArray