How do I save App-Server .JSON capture to .pcap (or serial *char)

Hey guys, so I’m trying to convert the .json log files that the Lorawan App Server generates to .pcap format. The idea is so that we can view/play with it in Wireshark/lbcap libraries.

The json files Im dealing with are the ones created on the LoRa App Server. They are an array of Lorawan packets and contain a real Lorawan payload.
See here for an example:
https://www.loraserver.io/lora-app-server/use/frame-logging/

I’m relatively new to my project and this Lora server source code, but I see there’s a considerable amount of logic/code for parsing data structures into JSON format for logging. Ive been looking over it for days and I can’t figure it out. Perhaps there is something in documentation that covers this, but nothing that I have been able to find yet.

I feel like there’s got to be a “right way” to do this. Sorry for the noob question.

This is impossible. You cannot unmarshal the json back into the golang PHYPayload object, or even a c* char (I mean you can, but it won’t mean anything).

You can easily marshal the PHYPayload object into json using the provided/standard encoder libraries (both produce same results). Then you can try to unmarshal it and it will always fail. Why? A subclass of PHYPayload is an interface. More specifically the Payload[] class. What does this mean you may ask? It must be implemented by a child class, and is determined by the MACPayload type. So if the compiler doesn’t know what type of MACPayload it is dealing with, it cannot impliment the interface class, and therefore cannot unmarshal

GOTO: lorawan/payload.go -> line 139 to see what I’m talking about

Why the hell would they put this in if you weren’t going to use it? I understand MongoDB is based in JSON, but can you really pull it out and view it/decrypt it/process it if its in a worthless Json format?