json_to_model icon indicating copy to clipboard operation
json_to_model copied to clipboard

add $key for all object and support private class name

Open thesadboy opened this issue 4 years ago • 5 comments

As the readme file shows, add $key for all object, not only in array. The $key value support private ClassName start by _ .

thesadboy avatar Nov 30 '21 10:11 thesadboy

i like that 👍

etoiledemer avatar Nov 30 '21 18:11 etoiledemer

@mark-apn can we merge this?

etoiledemer avatar Dec 20 '21 20:12 etoiledemer

Sorry for keeping you waiting. I'll take a look at this this week!

mark-nicepants avatar May 30 '22 18:05 mark-nicepants

Question about this PR.

Why not just change the key in the json in the first place.

{
   "movie": {
      "id": 123
   }
}

Will generate a Movie class and by changing the key movie you change the key in the output.

Why do we need this:

{
   "movie": {
      "$key":  "film",
      "id": 123,
   }
}

When we can just do this.

{
   "film": {
      "id": 123
   }
}

mark-nicepants avatar Jun 01 '22 07:06 mark-nicepants

if I remember correctly it helps fixing this : https://github.com/fadhilx/json_to_model/issues/30 without having to use separate files;

(when we have two keys with same name, but with different properties, it avoid name clashes in generated files)

etoiledemer avatar Jun 08 '22 00:06 etoiledemer