eiffelhub / json

Eiffel JSON library
Other
18 stars 13 forks source link

JSON_ARRAY JSON_VALUE returns #20

Open phgachoud opened 4 years ago

phgachoud commented 4 years ago

Trying to inherit from JSON_ARRAY I'd like to have a MY_JSON_VALUE used in all the routines, so much as parameter than as return type. Was there a reason to make those types anchored and not like items.item ???

Any way to refactor it? Pull request??

jocelyn commented 4 years ago

The lib sticks to the JSON specification, and the set of JSON values are limited. So using JSON_VALUE sounds easier to read rather than like items.item

However, if this is possible, I invite you to send a pull request with what you have in mind, and maybe with an example.

phgachoud commented 4 years ago

My point on this is

class MY_JSON_ARRAY

inherit
    JSON_ARRAY
        redefine
            items
        end

feature {NONE} -- Implementation

    items: ARRAYED_LIST[MY_JSON_VALUE]

end

instead of having to redefine everything because they are anchored types!

class MY_JSON_ARRAY

inherit
    JSON_ARRAY
        redefine
            items,
            put,
            ......
        end

feature {NONE} -- Implementation

    items: ARRAYED_LIST[MY_JSON_VALUE]

end
jocelyn commented 4 years ago

Ad what would be the additional value of MY_JSON_VALUE ?

phgachoud commented 4 years ago

Ad what would be the additional value of MY_JSON_VALUE ?

None, actually I almost finished a pull request integrating the needs (or mines @least) for SCOOP integration. I'm in the process of testing them and will write you once done.

MY_JSON_VALUE was done only in the case no changes could have been done to JSON_VALUE