-
Notifications
You must be signed in to change notification settings - Fork 339
Fix: Consolidate JSON Info output into a single object #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Refactored `InfoWriterJson` to produce a single JSON object containing all information. This addresses the issue of fragmented JSON output (#147). The `writeStringPool` method now correctly adds its data to the main JSON object.
| super(writer); | ||
| JSONWriter jsonWriter = new JSONWriter(writer); | ||
| jsonWriter = jsonWriter.array(); | ||
| JSONObject jsonObject = new JSONObject(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to keep the base structure same, however, for this line, I'm uncertain if it should be placed immediately after the JSONWriter initialization or in this manner. Please let me know if this is not acceptable. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you,
- When JSONObject used all values will be hold on memory until flushed, but JSONWriter transfers all objects to stream instantly. May have impact when dealing with huge resources.
- There is mis structure and duplicates, please run your tests with verbose
-vflag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- There is mis structure and duplicates, please run your tests with verbose
-vflag.
I ensured that I tested with all available flags; however, I might be missing something (please point it out if you notice), here are my test results on two different APKs:
1:
$ java -jar build/libs/APKEditor-1.4.1.jar info -i test.apk -v -t json
[
{
"resource-packages":
[
{
"id":127,
"name":"you.in.spark.access.dots"
}
]
},
{
"id":2131689509,
"type":"string",
"name":"app_name",
"entries":
[
{
"qualifiers":"",
"value":"Access Dots"
}
]
},
{
"id":2131558400,
"type":"mipmap",
"name":"access_dots_logo",
"entries":
[
{
"qualifiers":"-mdpi",
"value":"res/mipmap-mdpi-v4/access_dots_logo.png"
},
{
"qualifiers":"-hdpi",
"value":"res/mipmap-hdpi-v4/access_dots_logo.png"
},
{
"qualifiers":"-xhdpi",
"value":"res/mipmap-xhdpi-v4/access_dots_logo.png"
},
{
"qualifiers":"-xxhdpi",
"value":"res/mipmap-xxhdpi-v4/access_dots_logo.png"
},
{
"qualifiers":"-xxxhdpi",
"value":"res/mipmap-xxxhdpi-v4/access_dots_logo.png"
}
]
},
{
"activities":
[
"you.in.spark.access.dots.AccessDotsHome",
"you.in.spark.access.dots.InformationDialog",
"com.google.android.gms.ads.AdActivity",
"com.google.firebase.auth.internal.GenericIdpActivity",
"com.google.firebase.auth.internal.RecaptchaActivity",
"com.google.android.gms.common.api.GoogleApiActivity",
"com.android.billingclient.api.ProxyBillingActivity"
]
},
{
"uses-permission":
[
"android.permission.ACCESS_FINE_LOCATION",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.INTERNET",
"android.permission.RECEIVE_BOOT_COMPLETED",
"android.permission.SYSTEM_ALERT_WINDOW",
"android.permission.WAKE_LOCK",
"com.android.vending.BILLING"
]
},
{
"package":"you.in.spark.access.dots",
"VersionCode":11,
"VersionName":"AD_3.6_BETA",
"application-class":"you.in.spark.access.dots.MyApplication",
"activity-main":"you.in.spark.access.dots.AccessDotsHome"
}
]2: Second one is tested on a large app so it's bit lengthy uploading as file here: out.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong about duplicates on my last comment, but seems like we need to do massive rework on "InfoWriterJson".
- The main objective of
infoinjsonformat is to provide universally parse-able information for secondary applications/services (e.g python scripts, web services, docker ...), for further processing. - As pointed by Enhancement Request: Nicer Json output for
infocommand #147 , for example if you want to pick "application-class" you still have to iterate all objects on root json. On future we might need to replace root json-array by json-object.
Just a suggestion:
{
"app": {
"package":"com.example",
"versionCode":123,
"versionName":"1.2.3"
},
"uses-permission":
[
"android.permission.READ_MEDIA_VIDEO",
"android.permission.READ_PHONE_STATE"
],
"activities":
[
"com.Activity1",
"com.Activity2"
]
}For now I am going to merge this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m also using it in my project and initially came to create an issue, but seeing there was already one and knowing you’re busy, I tried addressing it myself. However, regarding the "massive work," I’m not confident I can write it the way you do with how badly I write my projects 🙈, as I’ve seen how much consideration you put into your code structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow @AbhiTheModder thanks so much for doing this!
Refactored
InfoWriterJsonto produce a single JSON object containing all information. This addresses the issue of fragmented JSON output (#147). ThewriteStringPoolmethod now correctly adds its data to the main JSON object.