JSON List content must be a "object"

Skip to first unread message


Sep 29, 2021, 5:10:16 AMSep 29
to Bots Open Source EDI Translator
Hi All,

I receive a json file from a partner where some values are put into an array without a propertyname. for example "EANs" in the following json:

"Id": 12345,
"EANs": [
"Stock": 100,
"Properties": [
"Name": "Name",
"Value": "Value"

I try to create a grammar for it like:

structure = [

recorddefs = {
    ['BOTSID', 'M', 256, 'AN'],
    ['Id', 'C', 256, 'AN'],
    ['EANs', 'C', 256, 'AN'],
    ['Stock', 'C', 256, 'AN'],
    ['Properties', 'C', 256, 'AN'],
    ['BOTSID', 'C', 256, 'AN'],
    ['BOTSCONTENT', 'C', 4096, 'AN'],
    ['BOTSID', 'M', 256, 'AN'],

If i create a sublevel in the structure for "EANs", as the example above, i get the error: "ValueError: Expecting ':' delimiter: line 4 column 28 (char 47)"
because it's missing the 
If i remove the sublevel and just want to read "EANs" as a record, i get the error: "InMessageError: [J54]: List content must be a "object"."

Is there a way to tackle this issue?
Thanks, Hans

Eppye Bots

Sep 29, 2021, 4:49:46 PMSep 29
to 'Chuck Turco' via Bots Open Source EDI Translator
bots does not support this now.

kind regards, Henk-Jan Ebbers

You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/botsmail/30d58a0c-a436-4d20-90b4-b942b6211478n%40googlegroups.com.


Sep 30, 2021, 12:13:36 AMSep 30
to Bots Open Source EDI Translator
The way I handled this, was to convert the JSON to an XML first with the dicttoxml library, which then names all the elements "something_Item". Routescript as follows (including cleaning out some unwanted characters):

import os
import bots.preprocess as preprocess
from bots.botsconfig import *
import bots.botslib as botslib
import bots.botsglobal as botsglobal
import json
import dicttoxml
import re

LIST_ID_EXT = 'Item'

def postincommunication(routedict, *args, **kwargs):
''' function is called after the communication in the route.'''

def make_xml(ta_from, endstatus, *args, **kwargs):
my_item_func = lambda x: x + '_' + LIST_ID_EXT
# copy ta for preprocessing
ta_to = ta_from.copyta(status=endstatus)
# open the files
content = botslib.readdata(filename=ta_from.filename)
obj = json.loads(content)
xml = dicttoxml.dicttoxml(
xml_cleaned = re.sub(u'[^\n\r\t\x20-\x7f]+',u'',xml)
# copy to next transaction
destfile = botslib.abspathdata(str(ta_to.idta))
with open(destfile, 'w') as f:
# update outmessage transaction with ta_info;
ta_to.update(statust=OK, filename=str(ta_to.idta))
except Exception as exc:
txt = botslib.txtexc()
botsglobal.logger.error(u'Custom preprocess failed. Error:\n%s', txt)
raise botslib.InMessageError(
u'Custom preprocess failed. Error:\n$error', error=txt)


Sep 30, 2021, 4:32:03 AMSep 30
to Bots Open Source EDI Translator
Hi Wassily, 

Thanks for tip, however the partner allready has a xml version of their stockfeed, but they insert some html content which messes up the file.
if i convert the json variant to xml i'll get the same issue :)
I guess i have to find out how to decrappify their html infested XML file then...
Op donderdag 30 september 2021 om 06:13:36 UTC+2 schreef Wassily:
Reply all
Reply to author
0 new messages