ParseFile init without previous fetch

I don’t fully understand your question, but a ParseFile along with ParseObject is Encodable and Decodable via:

Every ParseObject allows you to retrieve the proper encoded form with the className prepended using description or debugDescription:

My guess is you are running into issues because your JSON encoder/decoder isn’t configured to handle ParseObject's correctly. I say this because if ParseFile wasn’t encodable/decodable, it would mean you can’t save/retrieve files from a Parse Server, a number of tests on the SDK should have failed, and the Playgrounds wouldn’t work properly. It could also be because you are using Codable which technically ParseTypes are, but they don’t conform to Codable directly. Instead, they are all Encodable and Decodable, not sure if the compiler resolves this for you… To encode any ParseObject or Parse Type, you should be using the included Parse encoders/decoder. These can be accessed by looking at some code from one of my projects:

You can use any instance of one of your ParseObject’s as they will all give you the same encoders/decoders. The ones it seems you are interested in are: jsonEncoder and decoder. You shouldn’t use encoder for your local storage is this is the required encoded needed to send objects to the server.

1 Like