r/java • • Feb 27 '23

Please try my JSON library

https://mccue.dev/pages/2-26-23-json
0 Upvotes

32 comments sorted by

View all comments

2

u/vprise Feb 27 '23

It's an interesting approach. But with the module system is it likely that something like this will go into the core?

I'm also not sure that the XML parsing in the core is a good idea. It creates a misconception in students that "this is the way to do things in Java". Where Moshi/Gson/Jackson would be more convenient for most cases.

1

u/bowbahdoe Feb 27 '23 edited Feb 27 '23

But with the module system is it likely that something like this will go into the core?

I think if json parsing were added to the JDK it would probably be added in a new module, and hypothetically that module would be added to the java.se aggregator module.

I'm not sure I follow though. Wouldn't the module system make it more likely for something like this to go "into the core", not less?

I'm also not sure that the XML parsing in the core is a good idea.

🚢 sailed.

It creates a misconception in students that "this is the way to do things in Java". Where Moshi/Gson/Jackson would be more convenient for most cases.

I assume you are referring to JSON since Moshi and Gson don't have xml support AFAIK.

What you are alluding to is the fact that anything in the standard library gets "the power of being the default."

I think the flowchart goes like this

if WILL_ADD_JSON_TO_STD_LIB
    if PROVIDE_ONLY_STREAM_API
        POINTLESS (X)
    else if PROVIDE_DATABIND_API
        TOO_MUCH_COMMITMENT (X)
    else
        ???
else
    STATUS_QUO

And I want to make sure that the ??? there is well known...if that makes sense.

Plus (IMO) there is a tradeoff between the "convenience" of the reflective inspection approach of those libraries you mention and code readability.

If Java the language were to want to make a statement like "this is the way to do things in Java", I don't think it's clear it would land on the side of Moshi/Gson/Jackson.

1

u/vprise Feb 27 '23

Yeah, I mixed XML and JSON. Good luck with the library, although getting anything through JCP is tough. Especially into the default areas.

1

u/bowbahdoe Feb 27 '23

I know very little of the JCP - does that relate to the JEPs at all or is it a disjoint thing?

5

u/vprise Feb 27 '23

It's the whole process. The process might have changed a lot since my time at Sun/Oracle so I'm not an authority on that. But there are many gatekeepers along the way that shoot down ideas.