Read "weeks of month" information from JSON.
@param json the JSON where information is read from.
@return the list of weeks read, defaults to the empty list.
327568
private SortedSet<WeekOfMonth> readWeeksOfMonth(JSONObject json) {

        try {
            JSONArray array = json.getJSONArray(JsonKey.PATTERN_WEEKS_OF_MONTH);
            if (null != array) {
                SortedSet<WeekOfMonth> result = new TreeSet<>();
                for (int i = 0; i < array.length(); i++) {
                    try {
                        WeekOfMonth week = WeekOfMonth.valueOf(array.getString(i));
                        result.add(week);
                    } catch (JSONException e) {
                        LOG.debug("Could not read week of month from JSON. Skipping that particular week of month.", e);
                    }
                }
                return result;
            }
        } catch (JSONException e) {
            LOG.debug("Could not read week of month information from JSON", e);
        }
        return new TreeSet<>();
    }
823127
private JSONObject patternToJson() {

        JSONObject pattern = new JSONObject();
        if (null != getPatternType()) {
            pattern.put(JsonKey.PATTERN_TYPE, new JSONString(getPatternType().toString()));
            switch (getPatternType()) {
                case DAILY:
                    if (isEveryWorkingDay()) {
                        pattern.put(JsonKey.PATTERN_EVERYWORKINGDAY, JSONBoolean.getInstance(true));
                    } else {
                        pattern.put(JsonKey.PATTERN_INTERVAL, new JSONString(String.valueOf(getInterval())));
                    }
                    break;
                case WEEKLY:
                    pattern.put(JsonKey.PATTERN_INTERVAL, new JSONString(String.valueOf(getInterval())));
                    pattern.put(JsonKey.PATTERN_WEEKDAYS, toJsonStringList(getWeekDays()));
                    break;
                case MONTHLY:
                    pattern.put(JsonKey.PATTERN_INTERVAL, new JSONString(String.valueOf(getInterval())));
                    if (null != getWeekDay()) {
                        pattern.put(JsonKey.PATTERN_WEEKS_OF_MONTH, toJsonStringList(getWeeksOfMonth()));
                        pattern.put(JsonKey.PATTERN_WEEKDAYS, toJsonStringList(getWeekDays()));
                    } else {
                        pattern.put(JsonKey.PATTERN_DAY_OF_MONTH, new JSONString(String.valueOf(getDayOfMonth())));
                    }
                    break;
                case YEARLY:
                    pattern.put(JsonKey.PATTERN_MONTH, new JSONString(String.valueOf(getMonth())));
                    if (null != getWeekDay()) {
                        pattern.put(JsonKey.PATTERN_WEEKS_OF_MONTH, toJsonStringList(getWeeksOfMonth()));
                        pattern.put(JsonKey.PATTERN_WEEKDAYS, toJsonStringList(getWeekDays()));
                    } else {
                        pattern.put(JsonKey.PATTERN_DAY_OF_MONTH, new JSONString(String.valueOf(getDayOfMonth())));
                    }
                    break;
                case INDIVIDUAL:
                    pattern.put(JsonKey.PATTERN_DATES, datesToJsonArray(getIndividualDates()));
                    break;
                case NONE:
                default:
                    break;
            }
        }
        return pattern;
    }
549863
private Object readJSON() throws JSONException {
        switch (read(3)) {
        case zipObject:
            return readObject();
        case zipArrayString:
            return readArray(true);
        case zipArrayValue:
            return readArray(false);
        case zipEmptyObject:
            return new JSONObject();
        case zipEmptyArray:
            return new JSONArray();
        case zipTrue:
            return Boolean.TRUE;
        case zipFalse:
            return Boolean.FALSE;
        default:
            return JSONObject.NULL;
        }
    }
852376
@SuppressWarnings("UnusedDeclaration")
  public static Bindings fromJson( String json )
  {
    try
    {
      return PARSER.get().parseJson( json );
    }
    catch( ScriptException e )
    {
      throw new RuntimeException( e );
    }
  }
845150
@SuppressWarnings({"unchecked"})
    public <T> T read(URL jsonURL) throws IOException {
        return read(jsonURL, Configuration.defaultConfiguration());
    }
616808
public static Map<?, ?> parseJson(String body) {
        JSONReader jr = new JSONValidatingReader();
        Object obj = jr.read(body);
        if (obj instanceof Map<?, ?>) {
            return (Map<?, ?>) obj;
        } else {
            return null;
        }
    }
105019
public static final AuthToken fromJSON(String json) {
        try {
            return mapper.reader(AuthToken.class).readValue(json);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
573582
private Month readOptionalMonth(JSONValue val) {

        String str = readOptionalString(val);
        if (null != str) {
            try {
                return Month.valueOf(str);
            } catch (@SuppressWarnings("unused") IllegalArgumentException e) {
                // Do nothing -return the default value
            }
        }
        return null;
    }
498197
private SortedSet<Date> readDates(JSONValue json) {

        JSONArray array = null == json ? null : json.isArray();
        if (null != array) {
            SortedSet<Date> result = new TreeSet<>();
            for (int i = 0; i < array.size(); i++) {
                Date d = readOptionalDate(array.get(i));
                if (null != d) {
                    result.add(d);
                }
            }
            return result;
        }
        return new TreeSet<>();
    }
836237
public static List<EditLogFile> convertJsonToListManifest(String json)
      throws IOException {
    if (json == null || json.isEmpty()) {
      return new ArrayList<EditLogFile>();
    }
    // get the list of strings from the http response
    TypeReference<List<String>> type = new TypeReference<List<String>>() {
    };
    List<String> logFilesDesc = mapper.readValue(json, type);

    // we need to convert the list of strings into edit log files
    List<EditLogFile> logFiles = new ArrayList<EditLogFile>();
    for (String lf : logFilesDesc) {
      logFiles.add(new EditLogFile(lf));
    }
    return logFiles;
  }
449006
public static Object fromJson(String json) {
    try {
      JSONObject jsonObject = new JSONObject(json);
      if (jsonObject.has("JSON")) {
        return convert(jsonObject.get("JSON"));
      } else {
        return convert(jsonObject);
      }
    } catch (Exception e) {
      throw new RuntimeException("json=" + json, e);
    }
  }
501244
public List<Object> getAllJsonPath(String json, String jsonPath) {
        List<Object> result;
        if (JsonPath.isPathDefinite(jsonPath)) {
            Object val = getJsonPath(json, jsonPath);
            if (val == null) {
                result = Collections.emptyList();
            } else {
                result = Collections.singletonList(val);
            }
        } else {
            result = parseJson(json).read(jsonPath);
        }
        return result;
    }
552850
public void readJson(ConfigurationBuilderInfo builderInfo, String json) {
      readJson(builderInfo, "", Json.read(json));
   }
793802
public static ReadContext fromJson(String json) {
        Objects.requireNonNull(json, Required.JSON.toString());
        
        return JsonPath.parse(json);
    }
721984
def read_json(self):
        
        with reading_ancillary_files(self):
            if self.json_uri is None:
                metadata = self._read_json_db()
            else:
                metadata = self._read_json_file()
            if 'properties' in metadata:
                for name, prop in list(metadata['properties'].items()):
                    try:
                        self.set(prop['name'], prop['value'], prop['xml_path'])
                    except KeyError:
                        # we just skip if we don't have something, we want
                        # to have as much as possible read from the JSON
                        pass
        return metadata
449592
private JSONArray readOptionalArray(JSONObject json, String key) {

        try {
            return json.getJSONArray(key);
        } catch (JSONException e) {
            LOG.debug("Reading optional JSON array failed. Default to provided default value.", e);
        }
        return null;
    }
78848
public void json(String json) {
    if (LogLevel.DEBUG < logConfiguration.logLevel) {
      return;
    }
    printlnInternal(LogLevel.DEBUG, logConfiguration.jsonFormatter.format(json));
  }