2

I am currently working on both a plugin and an ida-python script that export fairly big JSON files.

I just noticed, that both will at times cut off the output files with no error message. Sometimes they will cut off at 8192 Characters and sometimes at roughly 220000 Characters. What is of particular interest to me is the fact that the files are constructed differently.

In the C++ Plugin I open a filepointer and construct the JSON-Data while cycling through my sample like this:

FILE *fp;
fp = qfopen("C:\\output.json" ,"w");
qfprintf(fp,"{\"filename\": \"%s\", \"functions\":[ ", filename);

In the Python Script I construct a (big) dictionary and use

fn=GetInputFile()+'.json'
f=open(fn,'w')
f.write(json.dumps(jsonfunc))

Of course I will need my output file intact, but I can't find any help googling. Still I feel like I'm missing something really trivial.

Best regards

Edit: Fixed by using

qflush(fp) //<-within the workloop
qfclose(fp)

and for the python script respectively:

f.close()
  • Is your Python script executed without exception? Do you close the file with f.close()? – ebux Jun 18 '15 at 5:50
  • > In the Python Script I construct a (big) dictionary and use ... mb a problem in that you don't have enough memory? – DOD Jun 18 '15 at 6:57
  • Hey, great point about the f.close() that fixed it for the Python Script. I also looked up similar function for my Plugin and using qflush(fp) & qfclose(fp) did the trick. – Viktor K Jun 18 '15 at 7:18
  • Maybe answer your own question so that the solution is easier to find? – tmr232 Jul 16 '15 at 22:42
  • Sorry, was not aware that this was possible. I edited had edited the original Question to reflect my solution. Thanks for the heads-up. – Viktor K Jul 21 '15 at 9:51
0

Fixed in the Plugin by using

qflush(fp) //<-within the workloop
qfclose(fp)

and for the Python script respectively:

f.close()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.