c3c icon indicating copy to clipboard operation
c3c copied to clipboard

JSON Serialisation

Open burakssen opened this issue 1 year ago • 8 comments

Json parsing is already implemented I assume, I think Json serialisation would be a great addition. Like with swift.

Defining a struct like

struct Person {
  let name: String
  let age: Int
}

JSONSerialization can directly create an Item object from

{
  "name": "Burak",
  "age": 24
}

I am not sure how this can be developed but, I can start something if this is inline with the project.

burakssen avatar Aug 31 '24 15:08 burakssen

It's quite straightforward with C3 actually. I just haven't bothered writing it as I don't think it's super useful.

lerno avatar Sep 01 '24 23:09 lerno

Yeah, I think the feature looked cool to me probably because swift has a weird object system 😅

burakssen avatar Sep 02 '24 00:09 burakssen

@lerno : Is C3 going to support more than the standard c library? I think betterC is fine with it. Extras can live in another repo.

This one can be ported for example or just used

https://github.com/barrust/c-utils

fithisux avatar Sep 11 '24 08:09 fithisux

@fithisux there is a standard library in C3, so I don't understand the question.

lerno avatar Sep 11 '24 08:09 lerno

The idea is not to overload it with many things. Also I was under the impression that it uses only stdc like betterC.

I will delve deeper.

fithisux avatar Sep 11 '24 08:09 fithisux

No, C3 has a cross platform standard library.

lerno avatar Sep 11 '24 08:09 lerno

A standardised way of serialising JSON would be very helpful, I think it would be a big improvement on having many different ad-hoc solutions for it.

joshring avatar Sep 16 '24 08:09 joshring

There is currently a JSON encoder in the std lib. In theory you would just need to make the inverse of this. Unless I missed something here?

Caleb-o avatar Sep 16 '24 08:09 Caleb-o