B4A Library [B4X] CodeBundle – Export Projects as a Single JSON for AI Analysis

The purpose of this tool is to easily export the complete project as a single json file which can be then fed to ChatGPT or any other capable AI bot for further analysis. It exports the modules code, layouts and some additional meta information.

This is an experimental tool. Please provide feedback if you find it useful or have any other suggestion.

Usage:

- Download the jar file and put it in the additional libraries folder, preferably under the B4X folder.
- Add to Main or B4XMainPage:
B4X:
#Macro: Title, Code bundle, ide://run?File=%ADDITIONAL%\..\B4X\CodeBundle.jar&Args=%PROJECT_NAME%
The path is set with the assumption that the additional libraries folder is set as recommended: https://www.b4x.com/android/forum/threads/b4x-additional-libraries-folder.103165/#content
Change it as needed.

- Click on Ctrl + 1 or the title bar button to export the project.

Notes:

- The following optional parameters are supported:

vmargs=-DHandleLayouts%3DFalse - To omit the layout files.
vmargs=-DCompactJson&3DFalse - To generate non-compact json.
vmargs=-DDontShowExplorer%3DTrue - Prevent file explorer from opening.

Source code is also attached.

- Save the project before running if you made changes. The tool reads the code from the project files.

Updates:

v0.2 - API keys are replaced with all-zeros key. This is done heuristically based on several regex patterns. Replaced keys are logged. If you encounter a key that isn't replaced then please post an example.
Information about referenced b4xlibs is added to the output.

Download link: www.b4x.com/android/files/CodeBundle.jar
 

Attachments

  • Source code.zip
    7.9 KB · Views: 9
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Example with ChatGPT (plus):

I've generated the json of B4XTable project:

1766588118567.png


Output:

In B4XTable, there are 4 column types (constants on the class): TEXT, NUMBERS, DATE, VOID.

1) COLUMN_TYPE_TEXT​


  • SQL storage: created as TEXT.

Search: only TEXT columns are searchable (Searchable = True). Filtering uses LIKE ? on searchable columns.


Display: read with rs.GetString(...) and placed into the label; if search highlighting is enabled it can render highlighted matches.


Sort: sortable (like everything except VOID).

2) COLUMN_TYPE_NUMBERS​


  • SQL storage: INTEGER (note: even though you might insert doubles, the table schema uses INTEGER for non-text).

Search: not searchable.


Display: read with rs.GetDouble(...) and formatted via the column’s Formatter (defaults to DefaultDataFormatter).


Sort: sortable (SQL ORDER BY on the column).


3) COLUMN_TYPE_DATE​


  • SQL storage: INTEGER (date is stored as a Long ticks value, typical DateTime style).

  • Search: not searchable.

Display: read with rs.GetLong(...) and shown as DateTime.Date(longValue).


Sort: sortable.

4) COLUMN_TYPE_VOID​


  • Purpose: “UI-only” / placeholder columns (not part of the SQL data model).
  • SQL storage: not stored — VOID columns are skipped when building the SQL table, inserts, and selects.

Not bad.

First suggestion: Make it simple to generate json from b4xlibs. Will do...
 

JohnC

Expert
Licensed User
Longtime User
I haven't tried this tool yet, but one thought that came to mind is if this tool could incorporate a Conditional Symbol such as "CODEBUNDLE" so that it can automatically/optionally use alternative values for certain code/info that you don't want to send to the AI:
B4X:
#IF CODEBUNDLE
    APIKey = "xxxxxxxxxx"    'fake key
#ELSE
    APIKey = "AADD832-428HWEWLJEW-RWEYRWR"    'real key
#END IF

This way fake info will always be sent to the AI even in the event you forgot to manually switch build configurations before running this tool.
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Wow, awesome, is there an option not to export particular file?

For example, I am using an env.json file to store security settings and other things for my project that I would not like to share with AI, will it be possible to have a command to exclude such an asset file?

Again, thanks so much for this tool. What a christmas present!! ;)
 
Top