Examples of JSONNumber


Examples of flexjson.JsonNumber

* to the underlying type found in the JSON stream in these situations we need to convert
* the JsonNumber to something valid: Double or Long.
*/
public class JsonNumberObjectFactory implements ObjectFactory {
    public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass) {
        JsonNumber number = (JsonNumber) value;
        if( number.isLong() ) {
            return number.longValue();
        } else {
            return number.doubleValue();
        }
    }
View Full Code Here

Examples of javax.json.JsonNumber

        mockQuery(Registration.findAll, registrations);
        final JsonArray result = this.cut.allAsJson();
        assertNotNull(result);
        assertThat(result.size(), is(1));
        JsonObject actual = result.getJsonObject(0);
        JsonNumber actualId = actual.getJsonNumber(Registrations.CONFIRMATION_ID);
        assertThat(expected.getId(), is(actualId.longValue()));

    }
View Full Code Here

Examples of org.sourceforge.jsonedit.core.outline.elements.JsonNumber

   */
  private void doJsonNumber(String key, int start) throws JsonReaderException, JsonTextOutlineParserException, BadLocationException, BadPositionCategoryException {
   
    boolean decimalPointSet = false;
   
    JsonNumber jsonNumber = new JsonNumber(parent, key);
    parent.addChild(jsonNumber);
    jsonNumber.setStart(start, doc);
   
    StringBuilder numberBuilder = new StringBuilder();
    numberBuilder.append(parser.getCurrent());
   
    char ch;
    do {
      ch = parser.getNextChar();
     
      if (Character.isDigit(ch)) {
        numberBuilder.append(ch);
        continue;
      }
     
      if (!decimalPointSet && ch == point) {
        decimalPointSet = true;
        numberBuilder.append(ch);
        continue;
      }
     
      jsonNumber.setLength(parser.getPosition() - start);
      if (isClosed(ch)) {
       
        break;
      }
     
      if (isNotWhiteSpace(ch)) {
        JsonError jsonError = new JsonError(parent, "Value " + ch + " not expected here");
        parent.addChild(jsonError);
        throw new JsonTextOutlineParserException();
      }
     
     
      ch = parser.getNextClean();
      if (isNotClosed(ch)) {
        JsonError jsonError = new JsonError(parent, "Expected end value");
        parent.addChild(jsonError);
        throw new JsonTextOutlineParserException();
      }
     
      break;
    } while (ch != eof);
   
    jsonNumber.setValue(numberBuilder.toString());
  }
View Full Code Here

Examples of se.llbit.json.JsonNumber

            for (int j = 0; j < path.length-1; ++j) {
              obj = obj.get(path[j]).object();
            }
            JsonValue jsonValue;
            try {
              jsonValue = new JsonNumber(Integer.parseInt(value));
            } catch (Exception e) {
              jsonValue = new JsonString(value);
            }
            obj.set(path[path.length-1], jsonValue);
            writeSceneJson(file, desc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.