Posts

Showing posts with the label json

Parse Json with dynamic key with JQuery

<script  src="http://code.jquery.com/jquery-3.1.0.min.js"  integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="  crossorigin="anonymous"></script> <script> var json ={ "result": { "101010":["PRAVAT","SGSGSG","UKEMP5","UKENTD","WAUK01","MK87UK"], "202020":["CORA1E","PSASAS","EDCRJS","USHC01","USDR06"], "304050":["ERCDE2","DELT01","DECGKG","DEHC03","IS02","DEPI01"] }, "status":"SUCCESS" }; var obj = jQuery.parseJSON(JSON.stringify(json)); if (obj.status.toLowerCase() === "success") { for (var key in obj.result) { console.log("key >> "+key); if (obj.result.hasOwnProperty(key)) {   console.log(key ...

List of all countries in JSON

[ { "name" : "Afghanistan" , "code" : "AF" }, { "name" : "land Islands" , "code" : "AX" }, { "name" : "Albania" , "code" : "AL" }, { "name" : "Algeria" , "code" : "DZ" }, { "name" : "American Samoa" , "code" : "AS" }, { "name" : "AndorrA" , "code" : "AD" }, { "name" : "Angola" , "code" : "AO" }, { "name" : "Anguilla" , "code" : "AI" }, { "name" : "Antarctica" , "code" : "AQ" }, { "name" : "Antigua and Barbuda" , "code" : "AG" }, { "name" : "Argentina" , "code" : "AR" }, { "name" : ...

RESTful API + POST + json body

Library :        <dependency>             <groupId>com.fasterxml.jackson.core</groupId>             <artifactId>jackson-databind</artifactId>             <version>2.7.2</version>         </dependency> Mapper Class public class MapperUtil {     private final static ObjectMapper mapper = new ObjectMapper();     public static <T> T readAsObjectOf(Class<T> clazz, String value) {         try {             return mapper.readValue(value, clazz);         } catch (IOException e) {             logger.error(e.getMessage());      ...