Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Jenkins parse json keep order

Here is the solution: I realized that readJSON step is keeping the order so I try to take a look at its implementation.

readJSON uses net.sf.json.* library, in this library there is an option to parse string to jsonObject (with keeping the order of the keys!) by:

import  net.sf.json.JSONSerializer

def map = JSONSerializer.toJSON(jsonstr)
println(map)
NOTES:

if you want use it during a pipeline I suggest you to use readJSON step itself, otherwise, you'll need to approve this function from Manage Jenkins -> script approval
In this method empty properties will be net.sf.json.JSONNull which holds a textual value "null" -> if (someEmptyKey != null) always returns true (also when null) to avoid that, use: if (!someEmptyKey instanceof JSONNull )
Sources: docs, jenkins-implementation
Comment

PREVIOUS NEXT
Code Example
Javascript :: inappbrowser hide url 
Javascript :: Accessing HTML attributes in DOM 
Javascript :: findPotentialLikes javascript 
Javascript :: useThrottle 
Javascript :: javascript Implicit Conversion to Number 
Javascript :: java script layout engine error 
Javascript :: javascript Accessing Object Methods 
Javascript :: JavaScript Number Objects 
Javascript :: javascript Passing Parameter as Default Values 
Javascript :: javascript of the object properties to a single variable 
Javascript :: javascript "use strict" 
Javascript :: javascript Number() Method Used on Dates 
Javascript :: actionscript random randomfunction 
Javascript :: jQuery - Set 
Javascript :: javascript get days difference between two dates 
Javascript :: nodejs: express, morgan, mongoose package 
Javascript :: set angle in phaser 
Javascript :: phaser place on ellipse 
Javascript :: phaser mixed animation 
Javascript :: chakra ui with humburger menu 
Javascript :: JS table with rows that have alternating colours 
Javascript :: nodejs mongodb native reuse single connection 
Javascript :: white space below image next image 
Javascript :: react native geolocation 
Javascript :: last five characters of string javascript 
Javascript :: inertia.js 
Javascript :: javascript array map 
Javascript :: how to turn a string into an array javascript 
Javascript :: javascript map with arrow function 
Javascript :: check if file exists javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =