Converts input into a JSON object.

@param namesAndValues - expected sequence of corresponding name and value pairs (number of parameters must be even   ).
@return new string {name:value,name1:value1, etc.}
488693
public static String toJsonObject(Object... namesAndValues) {

        if (namesAndValues.length % 2 != 0) {
            throw new IllegalArgumentException("number or arguments must be even");
        }
        StringBuilder sb = new StringBuilder("{");

        int count = 0;

        while (true) {
            Object name = namesAndValues[count];
            sb.append("\"").append(name).append("\":");
            if (!(namesAndValues[count + 1] instanceof Number)) {
                if (namesAndValues[count + 1] == null) {
                    sb.append("null");
                } else {
                    sb.append("\"").append(namesAndValues[count + 1].toString()).append("\"");
                }
            } else {
                sb.append(namesAndValues[count + 1].toString());
            }

            if (count < (namesAndValues.length - 2)) {
                sb.append(",");
                count += 2;
            } else {
                sb.append("}");
                break;
            }
        }
        return sb.toString();
    }
833096
public String instantiate(String... keysAndValues) {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    for (int i = 0; i < keysAndValues.length; i += 2) {
      builder.put(keysAndValues[i], keysAndValues[i + 1]);
    }
    return instantiate(builder.build());
  }
1080278
public static String jsonToString(JsonNode node) {
        try {
            return node == null ? null : MAPPER.writeValueAsString(node);
        } catch (JsonProcessingException e) {
            throw new SdkClientException("Could not serialize JSON", e);
        }
    }
137727
@Post("/node/node")
    public JsonNode json1(@RequestObject JsonNode input) {
        final JsonNode name = input.get("name");
        return mapper.valueToTree(new Response(Response.SUCCESS, name.textValue()));
    }
625149
public String stringify(JsonNode json) {
        try {
            return mapper().writerWithDefaultPrettyPrinter().writeValueAsString(json);
        } catch (JsonProcessingException e) {
            throw new RuntimeException("Cannot stringify the input json node", e);
        }
    }
471473
public <T extends BasicMessage> BasicMessageWithExtraData<T> deserialize(String nameAndJson) {
        String[] nameAndJsonArray = fromHawkularFormat(nameAndJson);
        String name = nameAndJsonArray[0];
        String json = nameAndJsonArray[1];

        // The name is the actual name of the POJO that is used to deserialize the JSON.
        // If not fully qualified with a package then assume it is in our package.
        if (name.indexOf(".") == -1) {
            name = String.format("%s.%s", API_PKG, name);
        }

        try {
            Class<T> pojo = (Class<T>) Class.forName(name);
            return new BasicMessageWithExtraData(AbstractMessage.fromJSON(json, pojo), null);
        } catch (Exception e) {
            throw new RuntimeException("Cannot deserialize: [" + nameAndJson + "]", e);
        }
    }
625354
public Object[][] createNameValueTree(Object mxString[][], Map<String, Object> properties)
    {
        mxString = super.createNameValueTree(mxString, properties);
        if (properties != null)
        {
            mxString = this.addNameValue(mxString, DB_NAME, properties.get(DB_NAME));
            mxString = this.addNameValue(mxString, TABLE_NAME, properties.get(TABLE_NAME));
        }
        return mxString;
    }
467764
private synchronized Collection<IInputValue> annotatedValuesToInputValues(Collection<IAnnotatedValue> values) throws ModelException
    {
        restartInputsMap();
        Collection<IInputValue> inputValues = new HashSet<IInputValue>();
        for (IAnnotatedValue annotatedValue : values)
        {
            IInput input = input(annotatedValue);
            if (null == input)
            {
                throw new ServiceExecutionException("Cannot find a suitable input for value: " + annotatedValue, null);
            }
            inputValues.add(addInputValue(input, annotatedValue));
        }
        return inputValues;
    }
543260
private static String toJSON(Object data) {
        try {
            return mapper.writeValueAsString(data);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
142645
public JSONBuilder serialize(String name, Object value) {
        return quote(name).append(':').serialize(value);
    }
883856
public JsonArray names() throws JsonException {
        return nameValuePairs.isEmpty()
                ? null
                : new JsonArray(new ArrayList<String>(nameValuePairs.keySet()));
    }
1189668
private static VarValueDef asValueDef( String valueName, JsonObject json)
    {
    try
      {
      VarValueDef valueDef = new VarValueDef( ObjectUtils.toObject( valueName));

      // Get the type of this value
      boolean failure = json.getBoolean( FAILURE_KEY, false);
      boolean once = json.getBoolean( ONCE_KEY, false);
      valueDef.setType
        ( failure? VarValueDef.Type.FAILURE :
          once? VarValueDef.Type.ONCE :
          VarValueDef.Type.VALID);

      if( failure && json.containsKey( PROPERTIES_KEY))
        {
        throw new SystemInputException( "Failure type values can't define properties");
        }

      // Get annotations for this value
      Optional.ofNullable( json.getJsonObject( HAS_KEY))
        .ifPresent( has -> has.keySet().stream().forEach( key -> valueDef.setAnnotation( key, has.getString( key))));
    
      // Get the condition for this value
      Optional.ofNullable( json.getJsonObject( WHEN_KEY))
        .ifPresent( object -> valueDef.setCondition( asValidCondition( object)));

      // Get properties for this value
      Optional.ofNullable( json.getJsonArray( PROPERTIES_KEY))
        .map( properties -> toIdentifiers( properties)) 
        .ifPresent( properties -> valueDef.addProperties( properties)); 

      return valueDef;
      }
    catch( SystemInputException e)
      {
      throw new SystemInputException( String.format( "Error defining value=%s", valueName), e);
      }
    }
944261
public static String serialize(Value value) throws JSONException {
		StringWriter writer = new StringWriter();
		Serializer.serialize(value, writer);
		return writer.toString();
	}
778835
public JSONArray jsonifyValues() {
        JSONArray jValues = new JSONArray();
        for (ValueEntry vEntry : values) {
            JSONObject o = new JSONObject();
            o.put("value",vEntry.getValue());
            o.put("timestamp",vEntry.getTimestamp());
            jValues.add(o);
        }
        return jValues;
    }
1224863
void toJSONString(final Map<ReferenceEqualityKey<JSONReference>, CharSequence> jsonReferenceToId,
            final boolean includeNullValuedFields, final int depth, final int indentWidth,
            final StringBuilder buf) {
        final boolean prettyPrint = indentWidth > 0;
        final int n = items.size();
        int numDisplayedFields;
        if (includeNullValuedFields) {
            numDisplayedFields = n;
        } else {
            numDisplayedFields = 0;
            for (final Entry<String, Object> item : items) {
                if (item.getValue() != null) {
                    numDisplayedFields++;
                }
            }
        }
        if (objectId == null && numDisplayedFields == 0) {
            buf.append("{}");
        } else {
            buf.append(prettyPrint ? "{\n" : "{");
            if (objectId != null) {
                // id will be non-null if this object does not have an @Id field, but was referenced by
                // another object (need to include ID_TAG)
                if (prettyPrint) {
                    JSONUtils.indent(depth + 1, indentWidth, buf);
                }
                buf.append('"');
                buf.append(JSONUtils.ID_KEY);
                buf.append(prettyPrint ? "\": " : "\":");
                JSONSerializer.jsonValToJSONString(objectId, jsonReferenceToId, includeNullValuedFields, depth + 1,
                        indentWidth, buf);
                if (numDisplayedFields > 0) {
                    buf.append(',');
                }
                if (prettyPrint) {
                    buf.append('\n');
                }
            }
            for (int i = 0, j = 0; i < n; i++) {
                final Entry<String, Object> item = items.get(i);
                final Object val = item.getValue();
                if (val != null || includeNullValuedFields) {
                    final String key = item.getKey();
                    if (key == null) {
                        // Keys must be quoted, so the unquoted null value cannot be a key
                        // (Should not happen -- JSONParser.parseJSONObject checks for null keys)
                        throw new IllegalArgumentException("Cannot serialize JSON object with null key");
                    }
                    if (prettyPrint) {
                        JSONUtils.indent(depth + 1, indentWidth, buf);
                    }
                    buf.append('"');
                    JSONUtils.escapeJSONString(key, buf);
                    buf.append(prettyPrint ? "\": " : "\":");
                    JSONSerializer.jsonValToJSONString(val, jsonReferenceToId, includeNullValuedFields, depth + 1,
                            indentWidth, buf);
                    if (++j < numDisplayedFields) {
                        buf.append(',');
                    }
                    if (prettyPrint) {
                        buf.append('\n');
                    }
                }
            }
            if (prettyPrint) {
                JSONUtils.indent(depth, indentWidth, buf);
            }
            buf.append('}');
        }
    }
330678
def fromJSON(value):
        
        j = json.loads(value)
        v = GPString()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
511828
private List<Node> createObjectsForQualifiedName(String namespace) {
    List<Node> objects = new ArrayList<>();
    String[] parts = namespace.split("\\.");

    createObjectIfNew(objects, parts[0], true);

    if (parts.length >= 2) {
      StringBuilder currPrefix = new StringBuilder().append(parts[0]);
      for (int i = 1; i < parts.length; ++i) {
        currPrefix.append(".").append(parts[i]);
        createObjectIfNew(objects, currPrefix.toString(), false);
      }
    }

    return objects;
  }