parse error: premature EOF

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
gio.cot
Posts: 10
Joined: Sat May 28, 2022 9:08 pm

parse error: premature EOF

Post by gio.cot »

we have a json variable with length more than 65535 (this json variable is the response of a web service !) ; when we try to run "docNode = yajl_buf_load_tree(%addr(json:*data) :%len(%trimr(json)):errMsg ); " in the docNode we find *NULL . The problem is the variable length ? how we can solve this problem ?
Thanks in advance
Gio

Json Example
P.S. is not important to import the encoded data
{
"order_nbr": "XXXXX-",
"delivery_booked": true,
"items": [
{
"item_number": "1",
"my_ord_id": "1074",
"tracking_url": "xxxxx"
}
],
"waybills": [
{
"from_code": "307",
"encoded": "JVBERi0xLjUKJeLjz9MKMyAwIG9iago8PC9TdWJ0eXBlL0Zvcm0vRmlsdGVyL0ZsYXRlRGVjb2RlL1R5cGUvWE9iamVjdC9NYXRyaXggWzEgMCAwIDEgMCAwXS9Gb3JtVHlwZSAxL1Jlc291cmNlczw8L1Byb2NTZXQgWy9QREYgL1RleHQgL0ltYWdlQiAvSW1hZ2VDIC9JbWFnZUldPj4vQkJveFswIDAgMTg5IDE4OV0vTGVuZ3RoIDI3NDg+PnN0cmVhbQp4nL1aQa4lORHcv1P8I7iqXK7yFZBYsGKB2CFAaIw0bLg+zsyIyHyIBRISak1ntCvy93Nk2L9/TP36aT/HO3/Wru3nl49hVvvvl89fP7///P1z/Pzzc/78ZrP+9jnaz28/f/hj+/nT59f963/8Av9d+//pryEr18ls+P2bbb/+8Re1sckq6d9tf8baEmfX5wgOq6+Du9eWOLuOMzisvg7uXlvi7HpfwWH1dXD32hJn196Dw+rr4O61Jc6u1x0cVl8Hd68tcXY9R3BYfR3c4wnurs5tb3BYfT24M+Sdoe4MUVlS2jfUekOsJzRCeVOpEZsfsfc7towycuN37PuObffYLcqde+6x5R47vmKjKD23u1cWn8+f8/HnKL4YtDNEOaEJpHiTTRPBQyFICJFcqBaiOaWamIJN2V1uT1eqFrZP10g+RgPnKHOeZb4T8zWSD9JAe8ukZ5lwrK0kbcBhz9IT3NmCOuMMc94os4nofiBh1+dMY8x0xAxHbIJPf1fMHEWemD+QC2I1STslKsRcnz2tEM9Bq/JKcDb4MTeen2cDfljtkYCOOlZX8gzc+OgJdN6xupJnwI+tPRLQoceIo8FHasBnrKHLBmzwARrPJ7XBnGWQmizoExJNKMRZqhZ5fN7k7MpxsmriMUHnDmzz7mWinDC4HVvs2OGFfbH2sj0/vuTsesLTrDrCsbbE8elz5qWHe8PWgtnSV3CZ0eCk9dl/SfjGQavektvY4JYynvvGgKwiIEthdSXPgKwiIEthdS ......... (continued for 120000 chars )
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: parse error: premature EOF

Post by jonboy49 »

Your third parm makes no sense. If you are using %addr(json:*data) as the second parm then the third should be %len(json) - no need for a trim.

Don't know why it would affect anything though.
gio.cot
Posts: 10
Joined: Sat May 28, 2022 9:08 pm

Re: parse error: premature EOF

Post by gio.cot »

Hi jonboy49

i tried also with this :
docNode = yajl_buf_load_tree(%addr(json:*data) :%len(json):errMsg );
but i have the same problem
Thanks
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: parse error: premature EOF

Post by jonboy49 »

How is the variable json defined? How is it populated? You're giving us very little to work with.
gio.cot
Posts: 10
Joined: Sat May 28, 2022 9:08 pm

Re: parse error: premature EOF

Post by gio.cot »

Hi jonboy49

Attached the json file that we receive as response, invoking a courier web service
let me know if you need more information.
Thanks in advance
Gio
Attachments
json encoded.rar
(89.64 KiB) Downloaded 167 times
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: parse error: premature EOF

Post by jonboy49 »

I still need what I asked for. How is the variable defined and how is it populated?

P.S. The file you sent is either corrupt or encrypted - it looks nothing like the data you posted earlier.
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: parse error: premature EOF

Post by Scott Klement »

I tried your JSON document with yajl_buf_load_tree, and it worked perfectly for me.

Something is wrong with your code that reads or the json and feeds it into yajl. Since we have no idea how your code works, we can't begin to help you. Provide a complete program that reproduces the problem so we can try it ourselves.
Post Reply