title: Generate a JSON from JSONObject that has keys saved as JsonPath, Java
body: <p>I have a JSONObject in which keys are stored as jsonPath and I want to create a JSON.</p>
  <pre><code>{
    &quot;officeName&quot;: &quot;string&quot;,
    &quot;bookingPolicies.spocCancelCutOff&quot;: 0,
    &quot;bookingPolicies.remoteSignInAllowed&quot;: true,
    &quot;bookingPolicies.wfhScheduleCutOff&quot;: 1,
    &quot;bookingPolicies.editBookingEnabled&quot;: true,
    &quot;bookingPolicies.wfhMaxDurationForBooking&quot;: 1,
    &quot;bookingPolicies.expiryCutOffInMinutes&quot;: 15,
    &quot;bookingPolicies.expiryNotificationCutOffInMinutes&quot;: 40,
    &quot;bookingPolicies.wfhMinShiftDurationInMinute&quot;: 180,
    &quot;bookingPolicies.wfhMaxShiftDurationInMinute&quot;: 720,
    &quot;bookingPolicies.timeDiffShiftsMin&quot;: 1,
    &quot;bookingPolicies.employeeEndTimeBookingCutoff&quot;: 2,
    &quot;bookingPolicies.maxHoursAllowedForCheckin&quot;: 0,
    &quot;bookingPolicies.gatepassDelaycutoff&quot;: 0,
    &quot;bookingPolicies.numOfDays&quot;: 2,
    &quot;officeUUID&quot;: &quot;a7829e63-3a80-4fca-abf6-3bc3d48832ee&quot;,
    &quot;bookingPolicies.wfhDisabled&quot;: true,
    &quot;bookingPolicies.checkInFirstPremise&quot;: false,
    &quot;bookingPolicies.maxShiftDuration&quot;: 0,
    &quot;bookingPolicies.limitEmployeeBookingDays&quot;: true,
    &quot;shiftSchedules.defineClockIn&quot;: true,
    &quot;bookingPolicies.wfhCancelCutOff&quot;: 1,
    &quot;bookingPolicies.onCallMinShiftDurationInMinute&quot;: 180,
    &quot;bookingPolicies.wfhBookingAllowed.key1&quot;: &quot;val2&quot;,
    &quot;bookingPolicies.defLogoutDuration&quot;: 10,
    &quot;bookingPolicies.limitEmployeeBookingDaysUnit&quot;: 4,
    &quot;bookingPolicies.blockUserIfNotVaccinated&quot;: true,
    &quot;bookingPolicies.showParking&quot;: true,
    &quot;seatBooking.isAutoEntryAllowed&quot;: false,
    &quot;bookingPolicies.wfhBookingAllowed.key4.key2[0]&quot;: &quot;val2&quot;,
    &quot;bookingPolicies.parkingSlotBufferTimeInMin&quot;: 1,
    &quot;bookingPolicies.bookingPerDayEmp&quot;: 12,
    &quot;bookingPolicies.defOnCallLogoutDurationInMinute&quot;: 540,
    &quot;bookingPolicies.employeeCancelCutOff&quot;: 5,
    &quot;bookingPolicies.minShiftDuration&quot;: 0,
    &quot;bookingPolicies.employeeScheduleCutoff&quot;: 2,
    &quot;bookingPolicies.defWfhLogoutDurationInMinute&quot;: 540,
    &quot;bookingPolicies.wfhEditCutOff&quot;: 1,
    &quot;bookingPolicies.onCallMaxShiftDurationInMinute&quot;: 720,
    &quot;bookingPolicies.wfhMonthlyLimit&quot;: 8,
    &quot;seatBooking.maxTimeBeforeClockin&quot;: false,
    &quot;bookingPolicies.bookingEditCutOff&quot;: 10,
    &quot;bookingPolicies.wfhClockInBuffer&quot;: 15,
    &quot;bookingPolicies.teamCalendarEnabled&quot;: true,
    &quot;bookingPolicies.seatBookingEnabled&quot;: true,
    &quot;bookingPolicies.enableRecurrenceOnTeamPlanner&quot;: true,
    &quot;bookingPolicies.wfhSpocSchecduleCutOff&quot;: 1,
    &quot;bookingPolicies.wfhWeeklyLimit&quot;: 2,
    &quot;bookingPolicies.employeeEndTimeScheduleCutoff&quot;: 0,
    &quot;bookingPolicies.wfhSpocEditCutOff&quot;: 1,
    &quot;bookingPolicies.minHoursAllowedForCheckin&quot;: 0,
    &quot;bookingPolicies.maxBufferForCheckin&quot;: 3,
    &quot;bookingPolicies.bookingLogoutEditCutOff&quot;: 0,
    &quot;bookingPolicies.spocScheduleCutOff&quot;: 0,
    &quot;bookingPolicies.wfhMinBetweenClockInClockOut&quot;: 0
  }
  </code></pre>
  <p>I am using recursive approach but I am not able to create nested jsonObject and arrayValues.
  Any library suggestions would also be great. Or how to use JsonObjects to create nested json.</p>