I am writing Java code in which I need to convert a JSONObject to JsonElement.Is there any way with which I can convert a JSONObject (org.json) to JsonElement (com.google.gson)?
One way that always works is to serialize the object in JSON and then parse it again:
JSONObject myData = ... Gson gson = new Gson(); JsonElement element = gson.fromJson(myData.toString(), JsonElement.class);
Source: https://habr.com/ru/post/1661053/More articles:C # Async Exception Wrapping - c #Numpy: ΠΊΠ°ΠΊ Π½Π°ΠΉΡΠΈ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΡΠΉ Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ ΠΌΠΈΠ½ΠΈΠΌΡΠΌ ΠΏΠΎΠ΄ΠΌΠ°ΡΡΠΈΡ Π² ΠΌΠ°ΡΡΠΈΡΠ΅ A? - pythonSpring JMS: set ErrorHandler for annotated @JmsListener method - javalist of data structure lists - how do I access linq? - c #Pass an object from child to parent component in React - javascriptHow to add Persistent Listener to Button.onClick in Unity Script editor - c #angular cli - adding cdn scripts / styles as a global priority - angularMoq: checking a method called with a specific delegate causes a "method argument length mismatch", - monoOUTER is applied without a subquery - joinCreating hasMany association elements - javascriptAll Articles