Convert nested JSON Keys to UPPERCASEHow do I override a Java map when converting a JSON to Java Object using GSON?How do I format a Microsoft JSON date?Can comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?Convert JSON to MapWhat is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Convert JS object to JSON stringHow do I convert a String to an int in Java?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?

What's the difference between const array and static const array in C/C++

Two researchers want to work on the same extension to my paper. Who to help?

Is it a Munchausen Number?

If a character drops a magic item that turns on/off, does that item turn off when they drop it?

What does this quote in Small Gods refer to?

No such column 'DeveloperName' on entity 'RecordType' after Summer '19 release on sandbox

Removing all characters except digits from clipboard

How to slow yourself down (for playing nice with others)

Finding the root cause of Spanning-Tree recalculations (on Cisco Nexus 9000s)

How did Thanos not realise this had happened at the end of Endgame?

What was the notion of limit that Newton used?

Why is the Sun made of light elements only?

We are two immediate neighbors who forged our own powers to form concatenated relationship. Who are we?

Is a vertical stabiliser needed for straight line flight in a glider?

Is there an application which does HTTP PUT?

Why is PerfectForwardSecrecy considered OK, when it has same defects as salt-less password hashing?

Why use steam instead of just hot air?

What does formal training in a field mean?

Which other programming languages apart from Python and predecessor are out there using indentation to define code blocks?

Remove color cast in darktable?

Why does the Earth follow an elliptical trajectory rather than a parabolic one?

Windows OS quantum vs. SQL OS Quantum

Why was the ancient one so hesitant to teach Dr Strange the art of sorcery

Should I pay on student loans in deferment or continue to snowball other debts?



Convert nested JSON Keys to UPPERCASE


How do I override a Java map when converting a JSON to Java Object using GSON?How do I format a Microsoft JSON date?Can comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?Convert JSON to MapWhat is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Convert JS object to JSON stringHow do I convert a String to an int in Java?How do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I want to convert all keys of JSON string/object to UPPERCASE in Java. The JSON can be nested.



I tried setting FieldNamingPolicy.UPPER_CAMEL_CASE in GsonBuilder but I guess that just works for String to JAVA Object and not for String to String.



 String payload = ""key" : "key1" : "value1","key2" : "value2"";
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapterFactory(myCustomTypeAdapterFactory);
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
Gson gson = gsonBuilder.create();
Map mapDeserialized = gson.fromJson(payload, Map.class);

System.out.println("Map " + mapDeserialized);


There are other solutions through JACKSON with custom TypeAdapterFactory but those only work for one level and not for nested.



"key" :
"key1" : "value1",
"key2" : "value2"



to



"KEY" :
"KEY1" : "value1",
"KEY2" : "value2"










share|improve this question
























  • Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

    – Michał Ziober
    Mar 23 at 11:02

















0















I want to convert all keys of JSON string/object to UPPERCASE in Java. The JSON can be nested.



I tried setting FieldNamingPolicy.UPPER_CAMEL_CASE in GsonBuilder but I guess that just works for String to JAVA Object and not for String to String.



 String payload = ""key" : "key1" : "value1","key2" : "value2"";
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapterFactory(myCustomTypeAdapterFactory);
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
Gson gson = gsonBuilder.create();
Map mapDeserialized = gson.fromJson(payload, Map.class);

System.out.println("Map " + mapDeserialized);


There are other solutions through JACKSON with custom TypeAdapterFactory but those only work for one level and not for nested.



"key" :
"key1" : "value1",
"key2" : "value2"



to



"KEY" :
"KEY1" : "value1",
"KEY2" : "value2"










share|improve this question
























  • Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

    – Michał Ziober
    Mar 23 at 11:02













0












0








0








I want to convert all keys of JSON string/object to UPPERCASE in Java. The JSON can be nested.



I tried setting FieldNamingPolicy.UPPER_CAMEL_CASE in GsonBuilder but I guess that just works for String to JAVA Object and not for String to String.



 String payload = ""key" : "key1" : "value1","key2" : "value2"";
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapterFactory(myCustomTypeAdapterFactory);
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
Gson gson = gsonBuilder.create();
Map mapDeserialized = gson.fromJson(payload, Map.class);

System.out.println("Map " + mapDeserialized);


There are other solutions through JACKSON with custom TypeAdapterFactory but those only work for one level and not for nested.



"key" :
"key1" : "value1",
"key2" : "value2"



to



"KEY" :
"KEY1" : "value1",
"KEY2" : "value2"










share|improve this question
















I want to convert all keys of JSON string/object to UPPERCASE in Java. The JSON can be nested.



I tried setting FieldNamingPolicy.UPPER_CAMEL_CASE in GsonBuilder but I guess that just works for String to JAVA Object and not for String to String.



 String payload = ""key" : "key1" : "value1","key2" : "value2"";
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapterFactory(myCustomTypeAdapterFactory);
gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
Gson gson = gsonBuilder.create();
Map mapDeserialized = gson.fromJson(payload, Map.class);

System.out.println("Map " + mapDeserialized);


There are other solutions through JACKSON with custom TypeAdapterFactory but those only work for one level and not for nested.



"key" :
"key1" : "value1",
"key2" : "value2"



to



"KEY" :
"KEY1" : "value1",
"KEY2" : "value2"







java json gson






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 10:04







Ankit Chauhan

















asked Mar 23 at 9:54









Ankit ChauhanAnkit Chauhan

449




449












  • Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

    – Michał Ziober
    Mar 23 at 11:02

















  • Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

    – Michał Ziober
    Mar 23 at 11:02
















Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

– Michał Ziober
Mar 23 at 11:02





Possible duplicate of How do I override a Java map when converting a JSON to Java Object using GSON?

– Michał Ziober
Mar 23 at 11:02












1 Answer
1






active

oldest

votes


















1














As you said FieldNamingPolicy is applied only for bean fields not for map keys. However UPPER_CAMEL_CASE is not what you want, it is camel case with first letter capitalized (SometingLikeThis). You have to implement your own deserializer that would do that for your:



import com.google.gson.*;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class UpperCaseAdapter implements JsonSerializer<Map<String, Object>>, JsonDeserializer<Map<String, Object>>
public static final Type TYPE = new TypeToken<Map<String, Object>>() .getType();

@Override
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context)
// TODO implement serialization if needed
return null;


@Override
public Map<String, Object> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet())
Object value = null;
if (entry.getValue().isJsonPrimitive())
value = entry.getValue().getAsString();
else if (entry.getValue().isJsonObject())
value = context.deserialize(entry.getValue(), TYPE); // deserialize the object using the same type
else if (entry.getValue().isJsonArray())
// TODO implement deserailization of array
else if (entry.getValue().isJsonNull())
// skip nulls
continue;

map.put(entry.getKey().toUpperCase(), value); //toUpperCase() is what we want

return map;




you can use the adapter then:



 String payload = ""key" : "key1" : "value1","key2" : "value2", "key3": "value"";
Gson gson = new GsonBuilder()
.registerTypeAdapter(UpperCaseAdapter.TYPE, new UpperCaseAdapter())
.create();
Map<String, Object> mapDeserialized = gson.fromJson(payload, UpperCaseAdapter.TYPE);

System.out.println("Map " + mapDeserialized);


and the output is:
Map KEY3=value, KEY=KEY2=value2, KEY1=value1






share|improve this answer























  • Will this solutions work for any level of nested JSON?

    – Ankit Chauhan
    Mar 23 at 11:11











  • Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

    – bambula
    Mar 23 at 11:15












  • Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

    – Ankit Chauhan
    Mar 23 at 11:33











  • You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

    – bambula
    Mar 23 at 12:47












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312524%2fconvert-nested-json-keys-to-uppercase%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














As you said FieldNamingPolicy is applied only for bean fields not for map keys. However UPPER_CAMEL_CASE is not what you want, it is camel case with first letter capitalized (SometingLikeThis). You have to implement your own deserializer that would do that for your:



import com.google.gson.*;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class UpperCaseAdapter implements JsonSerializer<Map<String, Object>>, JsonDeserializer<Map<String, Object>>
public static final Type TYPE = new TypeToken<Map<String, Object>>() .getType();

@Override
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context)
// TODO implement serialization if needed
return null;


@Override
public Map<String, Object> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet())
Object value = null;
if (entry.getValue().isJsonPrimitive())
value = entry.getValue().getAsString();
else if (entry.getValue().isJsonObject())
value = context.deserialize(entry.getValue(), TYPE); // deserialize the object using the same type
else if (entry.getValue().isJsonArray())
// TODO implement deserailization of array
else if (entry.getValue().isJsonNull())
// skip nulls
continue;

map.put(entry.getKey().toUpperCase(), value); //toUpperCase() is what we want

return map;




you can use the adapter then:



 String payload = ""key" : "key1" : "value1","key2" : "value2", "key3": "value"";
Gson gson = new GsonBuilder()
.registerTypeAdapter(UpperCaseAdapter.TYPE, new UpperCaseAdapter())
.create();
Map<String, Object> mapDeserialized = gson.fromJson(payload, UpperCaseAdapter.TYPE);

System.out.println("Map " + mapDeserialized);


and the output is:
Map KEY3=value, KEY=KEY2=value2, KEY1=value1






share|improve this answer























  • Will this solutions work for any level of nested JSON?

    – Ankit Chauhan
    Mar 23 at 11:11











  • Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

    – bambula
    Mar 23 at 11:15












  • Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

    – Ankit Chauhan
    Mar 23 at 11:33











  • You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

    – bambula
    Mar 23 at 12:47
















1














As you said FieldNamingPolicy is applied only for bean fields not for map keys. However UPPER_CAMEL_CASE is not what you want, it is camel case with first letter capitalized (SometingLikeThis). You have to implement your own deserializer that would do that for your:



import com.google.gson.*;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class UpperCaseAdapter implements JsonSerializer<Map<String, Object>>, JsonDeserializer<Map<String, Object>>
public static final Type TYPE = new TypeToken<Map<String, Object>>() .getType();

@Override
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context)
// TODO implement serialization if needed
return null;


@Override
public Map<String, Object> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet())
Object value = null;
if (entry.getValue().isJsonPrimitive())
value = entry.getValue().getAsString();
else if (entry.getValue().isJsonObject())
value = context.deserialize(entry.getValue(), TYPE); // deserialize the object using the same type
else if (entry.getValue().isJsonArray())
// TODO implement deserailization of array
else if (entry.getValue().isJsonNull())
// skip nulls
continue;

map.put(entry.getKey().toUpperCase(), value); //toUpperCase() is what we want

return map;




you can use the adapter then:



 String payload = ""key" : "key1" : "value1","key2" : "value2", "key3": "value"";
Gson gson = new GsonBuilder()
.registerTypeAdapter(UpperCaseAdapter.TYPE, new UpperCaseAdapter())
.create();
Map<String, Object> mapDeserialized = gson.fromJson(payload, UpperCaseAdapter.TYPE);

System.out.println("Map " + mapDeserialized);


and the output is:
Map KEY3=value, KEY=KEY2=value2, KEY1=value1






share|improve this answer























  • Will this solutions work for any level of nested JSON?

    – Ankit Chauhan
    Mar 23 at 11:11











  • Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

    – bambula
    Mar 23 at 11:15












  • Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

    – Ankit Chauhan
    Mar 23 at 11:33











  • You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

    – bambula
    Mar 23 at 12:47














1












1








1







As you said FieldNamingPolicy is applied only for bean fields not for map keys. However UPPER_CAMEL_CASE is not what you want, it is camel case with first letter capitalized (SometingLikeThis). You have to implement your own deserializer that would do that for your:



import com.google.gson.*;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class UpperCaseAdapter implements JsonSerializer<Map<String, Object>>, JsonDeserializer<Map<String, Object>>
public static final Type TYPE = new TypeToken<Map<String, Object>>() .getType();

@Override
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context)
// TODO implement serialization if needed
return null;


@Override
public Map<String, Object> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet())
Object value = null;
if (entry.getValue().isJsonPrimitive())
value = entry.getValue().getAsString();
else if (entry.getValue().isJsonObject())
value = context.deserialize(entry.getValue(), TYPE); // deserialize the object using the same type
else if (entry.getValue().isJsonArray())
// TODO implement deserailization of array
else if (entry.getValue().isJsonNull())
// skip nulls
continue;

map.put(entry.getKey().toUpperCase(), value); //toUpperCase() is what we want

return map;




you can use the adapter then:



 String payload = ""key" : "key1" : "value1","key2" : "value2", "key3": "value"";
Gson gson = new GsonBuilder()
.registerTypeAdapter(UpperCaseAdapter.TYPE, new UpperCaseAdapter())
.create();
Map<String, Object> mapDeserialized = gson.fromJson(payload, UpperCaseAdapter.TYPE);

System.out.println("Map " + mapDeserialized);


and the output is:
Map KEY3=value, KEY=KEY2=value2, KEY1=value1






share|improve this answer













As you said FieldNamingPolicy is applied only for bean fields not for map keys. However UPPER_CAMEL_CASE is not what you want, it is camel case with first letter capitalized (SometingLikeThis). You have to implement your own deserializer that would do that for your:



import com.google.gson.*;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class UpperCaseAdapter implements JsonSerializer<Map<String, Object>>, JsonDeserializer<Map<String, Object>>
public static final Type TYPE = new TypeToken<Map<String, Object>>() .getType();

@Override
public JsonElement serialize(Map<String, Object> src, Type typeOfSrc, JsonSerializationContext context)
// TODO implement serialization if needed
return null;


@Override
public Map<String, Object> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : json.getAsJsonObject().entrySet())
Object value = null;
if (entry.getValue().isJsonPrimitive())
value = entry.getValue().getAsString();
else if (entry.getValue().isJsonObject())
value = context.deserialize(entry.getValue(), TYPE); // deserialize the object using the same type
else if (entry.getValue().isJsonArray())
// TODO implement deserailization of array
else if (entry.getValue().isJsonNull())
// skip nulls
continue;

map.put(entry.getKey().toUpperCase(), value); //toUpperCase() is what we want

return map;




you can use the adapter then:



 String payload = ""key" : "key1" : "value1","key2" : "value2", "key3": "value"";
Gson gson = new GsonBuilder()
.registerTypeAdapter(UpperCaseAdapter.TYPE, new UpperCaseAdapter())
.create();
Map<String, Object> mapDeserialized = gson.fromJson(payload, UpperCaseAdapter.TYPE);

System.out.println("Map " + mapDeserialized);


and the output is:
Map KEY3=value, KEY=KEY2=value2, KEY1=value1







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 23 at 10:58









bambulabambula

1396




1396












  • Will this solutions work for any level of nested JSON?

    – Ankit Chauhan
    Mar 23 at 11:11











  • Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

    – bambula
    Mar 23 at 11:15












  • Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

    – Ankit Chauhan
    Mar 23 at 11:33











  • You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

    – bambula
    Mar 23 at 12:47


















  • Will this solutions work for any level of nested JSON?

    – Ankit Chauhan
    Mar 23 at 11:11











  • Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

    – bambula
    Mar 23 at 11:15












  • Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

    – Ankit Chauhan
    Mar 23 at 11:33











  • You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

    – bambula
    Mar 23 at 12:47

















Will this solutions work for any level of nested JSON?

– Ankit Chauhan
Mar 23 at 11:11





Will this solutions work for any level of nested JSON?

– Ankit Chauhan
Mar 23 at 11:11













Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

– bambula
Mar 23 at 11:15






Sure, you can try. There's a recursion that cares about any nested lvl. But if you expect to be an array in the json you have to improve the implementation.

– bambula
Mar 23 at 11:15














Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

– Ankit Chauhan
Mar 23 at 11:33





Thank yooouuu so much. I called the context again for each element of arrya and it worked for 4 levels.

– Ankit Chauhan
Mar 23 at 11:33













You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

– bambula
Mar 23 at 12:47






You're welcome. Just one thing - make sure, the the element of array is json object, if the element is primitive or another array then the call of context.deserialze won't work for the TYPE. The safest way for array deserialization is to implement another adapter, that would expect the json element to be json array and would go through the elements and if the element is object, then call deserialize for map TYPE, if element is array then call desrialize for array type and if element is primitive, then add element as string to the array.

– bambula
Mar 23 at 12:47




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55312524%2fconvert-nested-json-keys-to-uppercase%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript