Return the indicated claim value as a JsonValue

@param ip - injection point of the claim
@return a JsonValue wrapper
970067
public JsonValue generalJsonValueProducer(InjectionPoint ip) {
        String name = getName(ip);
        Object value = getValue(name, false);
        JsonValue jsonValue = wrapValue(value);
        return jsonValue;
    }
162943
def serialize(self):
        
        return json.dumps({
            "name": self.name,
            "ip": self.ip,
            "port": self.port
        }, sort_keys=True)
516861
private JsonObject toJsonObject() {
        JsonObjectBuilder factory = Json.createObjectBuilder();
        if (profile != null) {
            factory.add("profile", profile);
        }
        if (!hosts.isEmpty()) {
            JsonArrayBuilder ab = Json.createArrayBuilder();
            for (String host : hosts) {
                ab.add(host);
            }
            factory.add("hosts", ab.build());
        }
        if (label != null) {
            factory.add("label", label);
        }

        if (caName != null) {
            factory.add(HFCAClient.FABRIC_CA_REQPROP, caName);
        }
        factory.add("certificate_request", csr);

        if (attrreqs != null) {
            JsonArrayBuilder ab = Json.createArrayBuilder();
            for (AttrReq attrReq : attrreqs.values()) {
                JsonObjectBuilder i = Json.createObjectBuilder();
                i.add("name", attrReq.name);
                if (attrReq.optional != null) {
                    i.add("optional", attrReq.optional);
                }
                ab.add(i);

            }
            factory.add("attr_reqs", ab.build());
        }

        return factory.build();
    }
268969
@JsonValue
	public Object toJsonValue() {
		if (definition != null)
			return definition;
		if (reference != null)
			return reference;
		if (_null != null)
			return _null;
		return null;
	}
1099804
@JsonValue
	@Override
	public String value() {
		return isCuried() ? String.format("%s:%s", curie, localPart) : localPart;
	}
972971
def _get_ip_public(self, queue_target, url, json=False, key=None):
        """"""
        try:
            response = urlopen(url, timeout=self.timeout).read().decode('utf-8')
        except Exception as e:
            logger.debug("IP plugin - Cannot open URL {} ({})".format(url, e))
            queue_target.put(None)
        else:
            # Request depend on service
            try:
                if not json:
                    queue_target.put(response)
                else:
                    queue_target.put(loads(response)[key])
            except ValueError:
                queue_target.put(None)
575413
protected JsonWebSignature createJsonWebSignature(final JwtClaims claims) {
        val jws = new JsonWebSignature();
        val jsonClaims = claims.toJson();
        jws.setPayload(jsonClaims);
        jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.NONE);
        jws.setAlgorithmConstraints(AlgorithmConstraints.NO_CONSTRAINTS);
        return jws;
    }
127791
private Object jsonToObject(String recordValue) throws JsonParseException, JsonMappingException, IOException{
		ObjectMapper mapper = new ObjectMapper();
		Object json = mapper.readValue(recordValue, Object.class);	
		return json;
	}
1050216
private Map<String, Object> getUserinfoFromRegistryMap(Set<String> claims,
            Map<String, Object> inputMap,
            boolean isJson) throws Exception {
        Map<String, Object> result = inputMap;

        VMMService vmmService = JwtUtils.getVMMService();
        if (vmmService != null) {
            PropertyControl vmmServiceProps = new PropertyControl();
            Properties claimsToVMMProperties = new Properties();
            if (!claims.isEmpty()) {
                // Properties claimsToVMMProps = jwtConfig.getClaimToUserRegistryMap(); //TODO
                for (String claim : claims) {
                    String vmmProperty = claim;// claimsToVMMProps.getProperty(claim);
                    // if (vmmProperty == null) {
                    // vmmProperty = claim;
                    // if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    // Tr.debug(tc, "claim: " + claim + "  is not mapped to a vmm property, using the claim name as the vmm property name");
                    // }
                    // }
                    // else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    // Tr.debug(tc, "claim: " + claim + "  mapped to vmmProperty: " + vmmProperty);
                    // }

                    claimsToVMMProperties.put(claim, vmmProperty);
                    vmmServiceProps.getProperties().add(vmmProperty);
                }
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "claimsToVMMProperties: " + claimsToVMMProperties);
                Tr.debug(tc, "getting VMM properties: " + vmmServiceProps.getProperties());
            }
            if (!vmmServiceProps.getProperties().isEmpty()) {
                // Call VMM to get the user's properties
                // IdentifierType id = new IdentifierType();
                // String uniqueId = RegistryHelper.getUserRegistry(null).getUniqueUserId(userName);
                // id.setUniqueName(uniqueId);
                // Entity entity = new Entity();
                // entity.setIdentifier(id);
                // Root root = new Root();
                // root.getEntities().add(entity);
                // root.getControls().add(vmmServiceProps);
                // root = vmmService.get(root);
                // PersonAccount person = (PersonAccount) root.getEntities().get(0);
                PersonAccount person = getUser(vmmService, vmmServiceProps);
                // Now add the claims/values to the JSON
                for (Entry<Object, Object> e : claimsToVMMProperties.entrySet()) {
                    String claim = (String) e.getKey();
                    String vmmProperty = (String) e.getValue();
                    Object value = person.get(vmmProperty);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "get for claim: " + claim + "  vmmProperty: " + vmmProperty + ", returned: " + value);
                    }
                    String strValue = vmmPropertyToString(value);
                    if (strValue != null && !strValue.isEmpty()) {
                        result.put(claim, strValue);
                        // if (isJson && claim.equals("address")) {
                        // JSONObject addressJSON = new JSONObject();
                        // addressJSON.put("formatted", strValue);
                        // result.put(claim, addressJSON);
                        // } else {
                        // result.put(claim, strValue);
                        // }
                    }
                }
            }
        }
        else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "VMM service not available - not returning any extra claims");
            }
        }

        return result;
    }
970803
public JSONObject toJson() throws IOException, JSONException {
    JSONObject json = new JSONObject();

    for (CapabilityInstance option : options.values()) {
      Object value = option.getValue();

      if (value == null) {
        continue;
      }

      if (value instanceof OperaProfile) {
        value = ((OperaProfile) value).toJson();
      } else if (value instanceof OperaArguments && ((OperaArguments) value).size() > 0) {
        value = ((OperaArguments) value).toJson();
      } else if (value instanceof Boolean) {
        value = (Boolean) value ? 1 : 0;
      } else {
        value = String.valueOf(value);
      }

      json.put(option.getIdentifier(), value);
    }

    return json;
  }
454858
void processClaimProviderInjections(@Observes ProcessInjectionPoint<?, ? extends Provider> pip) {
        log.debugf("pip: %s", pip.getInjectionPoint());
        final InjectionPoint ip = pip.getInjectionPoint();
        if (ip.getAnnotated().isAnnotationPresent(Claim.class)) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
                pip.addDefinitionError(new DeploymentException("@Claim at: " + ip + " has no name or valid standard enum setting"));
            }
            boolean usesEnum = claim.standard() != Claims.UNKNOWN;
            final String claimName = usesEnum ? claim.standard().name() : claim.value();
            log.debugf("Checking Provider Claim(%s), ip: %s", claimName, ip);
            ClaimIP claimIP = claims.get(claimName);
            Type matchType = ip.getType();
            // The T from the Provider<T> injection site
            Type actualType = ((ParameterizedType) matchType).getActualTypeArguments()[0];
            // Don't add Optional or JsonValue as this is handled specially
            if (!optionalOrJsonValue(actualType)) {
                rawTypes.add(actualType);
            } else if (!actualType.getTypeName().startsWith("javax.json.Json")) {
                // Validate that this is not an Optional<JsonValue>
                Type innerType = ((ParameterizedType) actualType).getActualTypeArguments()[0];
                if (!innerType.getTypeName().startsWith("javax.json.Json")) {
                    providerOptionalTypes.add(actualType);
                    providerQualifiers.add(claim);
                }
            }
            rawTypeQualifiers.add(claim);
            ClaimIPType key = new ClaimIPType(claimName, actualType);
            if (claimIP == null) {
                claimIP = new ClaimIP(actualType, actualType, false, claim);
                claimIP.setProviderSite(true);
                claims.put(key, claimIP);
            }
            claimIP.getInjectionPoints().add(ip);
            log.debugf("+++ Added Provider Claim(%s) ip: %s", claimName, ip);

        }
    }
770122
private Object getJSONValue(Object value) throws JSONException {
    if (value instanceof Bundle) {
      return getJSONForBundle((Bundle) value);
    } else if (value instanceof CharSequence) {
      return value.toString();
    } else if (value instanceof List) {
      JSONArray array = new JSONArray();
      for (Object listValue : (List<?>) value) {
        array.put(getJSONValue(listValue));
      }
      return array;
    } else if (value instanceof SparseArray) {
      JSONArray array = new JSONArray();
      SparseArray<?> sparseValue = (SparseArray<?>) value;
      for (int i = 0; i < sparseValue.size(); i++) {
        array.put(sparseValue.keyAt(i), getJSONValue(sparseValue.valueAt(i)));
      }
      return array;
    } else if (value instanceof Character) {
      return value.toString();
    } else if (value instanceof Boolean) {
      return value;
    } else if (value instanceof Number) {
      if (value instanceof Double || value instanceof Float) {
        return ((Number) value).doubleValue();
      } else {
        return ((Number) value).longValue();
      }
    } else if (value instanceof boolean[]) {
      JSONArray array = new JSONArray();
      for (boolean arrValue : (boolean[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof char[]) {
      JSONArray array = new JSONArray();
      for (char arrValue : (char[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof CharSequence[]) {
      JSONArray array = new JSONArray();
      for (CharSequence arrValue : (CharSequence[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof double[]) {
      JSONArray array = new JSONArray();
      for (double arrValue : (double[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof float[]) {
      JSONArray array = new JSONArray();
      for (float arrValue : (float[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof int[]) {
      JSONArray array = new JSONArray();
      for (int arrValue : (int[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof long[]) {
      JSONArray array = new JSONArray();
      for (long arrValue : (long[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof short[]) {
      JSONArray array = new JSONArray();
      for (short arrValue : (short[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    } else if (value instanceof String[]) {
      JSONArray array = new JSONArray();
      for (String arrValue : (String[]) value) {
        array.put(getJSONValue(arrValue));
      }
      return array;
    }
    return null;
  }
1057642
private static String getJsonValue(JsonValue value) {
        String s = null;
        if (value != null) {
            s = getJsonValueAsString(value);
            if (s == null) {
                s = getJsonValueAsNumberString(value);
            }
            if (s == null) {
                Boolean b = getJsonValueAsBoolean(value);
                if (b != null) {
                    s = b ? "true" : "false";
                }
            }
        }
        return s;
    }
659698
public static JsonValue value(double value) {
    if (Double.isInfinite(value) || Double.isNaN(value)) {
      throw new IllegalArgumentException(INFINITE_AND_NAN);
    }
    return new JsonNumber(cutOffPointZero(Double.toString(value)));
  }
408761
def ip_to_geojson(ipaddress, name="Point"):
    """"""

    geo = ip_to_geo(ipaddress)

    point = {
        "type": "FeatureCollection",
        "features": [
            {
                "type": "Feature",
                "properties": {
                    "name": name
                },
                "geometry": {
                    "type": "Point",
                    "coordinates": [
                        geo["longitude"],
                        geo["latitude"]
                    ]
                }
            }
        ]
    }

    return point
949208
public static JSONObject getJSONObject(HttpGet request, Integer method) throws JSONException {
        return UpworkRestClient.getJSONObject(request, method, new HashMap<String, String>());
    }
305722
@Override
    public Builder claimFrom(String jsonOrJwt) throws InvalidTokenException {
        isValidToken(jsonOrJwt);
        String decoded = jsonOrJwt;
        if (JwtUtils.isBase64Encoded(jsonOrJwt)) {
            decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);
        }
        boolean isJson = JwtUtils.isJson(decoded);

        if (!isJson) {
            String jwtPayload = JwtUtils.getPayload(jsonOrJwt);
            decoded = JwtUtils.decodeFromBase64String(jwtPayload);
        }

        // boolean isJwt = JwtUtils.isJwtToken(jsonOrJwt);
        // String decoded = jsonOrJwt;
        // if (isJwt) {
        // String jwtPayload = JwtUtils.getPayload(jsonOrJwt);
        // decoded = JwtUtils.decodeFromBase64String(jwtPayload);
        //
        // } else {
        // // either decoded payload from jwt or encoded/decoded json string
        // if (JwtUtils.isBase64Encoded(jsonOrJwt)) {
        // decoded = JwtUtils.decodeFromBase64String(jsonOrJwt);
        // }
        // }

        // String formattedString = JwtUtils.fromBase64ToJsonString(jsonOrJwt);
        if (decoded != null) {
            Map claimsFromAnother = null;
            try {
                claimsFromAnother = JwtUtils.claimsFromJsonObject(decoded);
            } catch (JoseException e) {
                String err = Tr.formatMessage(tc, "JWT_INVALID_TOKEN_ERR");
                throw new InvalidTokenException(err);
            }
            if (claimsFromAnother != null && !claimsFromAnother.isEmpty()) {
                claims.putAll(claimsFromAnother);
            }
        }
        return this;
    }