in the assets folder for the b4a version (at least), you should find images.json and orgimages.json. the
latter is your original file. the former is how i turned a text file of disparate json strings into 1 json string
containing a list of json strings i could loop through with our usual json parser.
i happen to have done it with notepad++, but it could have been done programatically. but when i thought
a little about your file, i realized that it was possible to process it on a line by line basis without altering
the main program logic: the concatenation of chunks of base64 strings into a jpg image. so i reverted to
reading the file line by line.
the little commented snippet that you posted and called "not right" is the result of my modification. the
"]}" at the end are not in your file.
so, first, a list can hold anything, even another list. you normally don't want to mix what's in the list, as it
makes processing a little tricky, although - technically - a list of objects is probably legal, and you can leave
it to whoever comes after you to figure out how to process the list. anyway, whereas
a stringbuilder was applicable for concatenating base64 string chunks, it wouldn't work chunks of bytes.
so i switched to a list. you can't use an array to hold the chunks because java arrays can't be extended.
a list is limited only by memory. once all the chunks for a given image have been added to a list, you can
get back to an array, which is what is needed to create a bitmap. so you can think of a list as an
ever expanding array. you just need to get back to array for certain operations. in fact, java itself has a
built-in list.toArray() method to do just that. i think i looked at the methods our list supports; i don't recall
seeing a toArray() method.
as to what "Collection" is all about, your file is essentially 3 lines of json strings (i've truncated the strings to fit across the page instead of wrapping around):
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"0","BlobSegment":{"$binary": "/9j/4AAQSkZJRgABAAEAlgCWAAD// ...","$type": "00"},...}
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"1","Blob_Segment":{"$binary": "cAe3+e1Zq71ZjbX ...", "$type": "00"},...}
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"0","Blob_Segment":{"$binary": "/9j/4AAQSkZJRgABAAEAlgCWAAD ...", "$type": "00"},...}
to turn these 3 json strings in 1 big json string, you add some scaffolding:
{"Collection": [
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"0","BlobSegment":{"$binary": "/9j/4AAQSkZJRgABAAEAlgCWAAD// ...","$type": "00"},...}
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"1","Blob_Segment":{"$binary": "cAe3+e1Zq71ZjbX ...", "$type": "00"},...}
{"Blob_Person_ID":"zflas",...,"Blob_Segment_No":"0","Blob_Segment":{"$binary": "/9j/4AAQSkZJRgABAAEAlgCWAAD ...", "$type": "00"},...}
]}
if you look at the 1st and 3rd entries, you see the $binary values begin with "/9j". this is the base64 signature for a jpg file. if you look at the 2nd entry's $binary value, there is no such signature. it's the missing chunk belonging to the image started in entry 1. it needs to be added to entry 1. there is no law that says there might not be more chunks. your file sample only presented 2 chunks for the first image. you can see the "Blog_Segment_No" counting from 0. you add the chunks until you hit another segment 0 (new image)