
import scrapy


def single_item_serializer(value):
    # values are nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
    # so need to return just the fist value when serializing
    return value[0]


class JobsItem(scrapy.Item):
    title = scrapy.Field(serializer=single_item_serializer)
    company = scrapy.Field(serializer=single_item_serializer)
    url = scrapy.Field(serializer=single_item_serializer)
    posted = scrapy.Field(serializer=single_item_serializer)
    deadline = scrapy.Field(serializer=single_item_serializer)
    views = scrapy.Field(serializer=int)


import scrapy


def single_item_serializer(value):
    # values are sometimes nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
    # so need to return just the fist value when serializing
    if isinstance(value, (list, tuple)):
        return value[0]
    return value


class JobsItem(scrapy.Item):
    title = scrapy.Field(serializer=single_item_serializer)
    company = scrapy.Field(serializer=single_item_serializer)
    url = scrapy.Field(serializer=single_item_serializer)
    posted = scrapy.Field(serializer=single_item_serializer)
    deadline = scrapy.Field(serializer=single_item_serializer)
    views = scrapy.Field(serializer=int)

Fix rendering of alfred.is data to json file
Fix rendering of alfred.is data to json file

  
  import scrapy
  
  
  def single_item_serializer(value):
-     # values are nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
+     # values are sometimes nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
      # so need to return just the fist value when serializing
+     if isinstance(value, (list, tuple)):
+         return value[0]
-     return value[0]
+     return value
  
  
  class JobsItem(scrapy.Item):
      title = scrapy.Field(serializer=single_item_serializer)
      company = scrapy.Field(serializer=single_item_serializer)
      url = scrapy.Field(serializer=single_item_serializer)
      posted = scrapy.Field(serializer=single_item_serializer)
      deadline = scrapy.Field(serializer=single_item_serializer)
      views = scrapy.Field(serializer=int)
  
Fix rendering of alfred.is data to json file
## Code Before:

import scrapy


def single_item_serializer(value):
    # values are nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
    # so need to return just the fist value when serializing
    return value[0]


class JobsItem(scrapy.Item):
    title = scrapy.Field(serializer=single_item_serializer)
    company = scrapy.Field(serializer=single_item_serializer)
    url = scrapy.Field(serializer=single_item_serializer)
    posted = scrapy.Field(serializer=single_item_serializer)
    deadline = scrapy.Field(serializer=single_item_serializer)
    views = scrapy.Field(serializer=int)

## Instruction:
Fix rendering of alfred.is data to json file
## Code After:

import scrapy


def single_item_serializer(value):
    # values are sometimes nested inside a list: (u'Viltu vaxa me\xf0 Alvogen?',)
    # so need to return just the fist value when serializing
    if isinstance(value, (list, tuple)):
        return value[0]
    return value


class JobsItem(scrapy.Item):
    title = scrapy.Field(serializer=single_item_serializer)
    company = scrapy.Field(serializer=single_item_serializer)
    url = scrapy.Field(serializer=single_item_serializer)
    posted = scrapy.Field(serializer=single_item_serializer)
    deadline = scrapy.Field(serializer=single_item_serializer)
    views = scrapy.Field(serializer=int)
