JSON parsing on Embedded

Currently, without Foundation and Codable support, it's pretty hard to parse JSON in Embedded Swift.

I've ported my JSON Tokenizer and parser, IkigaJSON, to work on Embedded Swift. The PR is still a bit early to tag, as I don't think it's convenient enough yet. My current train of thought is to add a macro that helps with (de)serialization of JSON in embedded mode. What are your thoughts?

12 Likes

This is very exciting -- leaving aside the macro and convenience questions... Is the port functional under Embedded Swift? What were the challenges in porting?

1 Like

Hi @Joannis_Orlandos, nice to see you here! I’ll just quote my feedback from the GitHub issue page here:
Due to the dependency on Swift-NIO, I encountered tons of errors when trying to build it for a bare-metal environment😂. It seems all the errors come from the NIO package. After fixing some, even more popped up. But thank you for your new approach!

The parser is functional on embedded, without high-level APIs. I'm currently using CMake for this. I want to use SwiftPM down the line, but my ESP-IDF setup doesn't allow that yet.

There weren't really any big challenges for me, but I've done an internal parser library for Embedded Swift before. I'm also generally pretty comfortable with this type of code.

Currently I only support building the embedded bits with CMake, the higher level code needs NIO because I want parsing to work on a high level currency type for server use cases. With Span on the way, I'll be looking to adopt that.

I'd prefer packaging this with SwiftPM too, but it wasn't a priority for me as I use ESP-IDF right now.

2 Likes

Copy that! I'll dive a bit deeper then. Thanks!

1 Like