microsoft-azure-storage/src/com/microsoft/azure/storage/table/TableEntitySerializer.java
private static void writeJsonEntity(final JsonGenerator generator, final TableEntity entity,
            final boolean isTableEntry, final OperationContext opContext) throws StorageException, IOException {

        HashMap<String, EntityProperty> properties = entity.writeEntity(opContext);
        if (properties == null) {
            properties = new HashMap<String, EntityProperty>();
        }

        // start object
        generator.writeStartObject();

        if (!isTableEntry) {
            Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey());
            Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey());
            Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp());

            // PartitionKey
            generator.writeStringField(TableConstants.PARTITION_KEY, entity.getPartitionKey());

            // RowKey
            generator.writeStringField(TableConstants.ROW_KEY, entity.getRowKey());

            // Timestamp
            generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
        }

        for (final Entry<String, EntityProperty> ent : properties.entrySet()) {
            if (ent.getKey().equals(TableConstants.PARTITION_KEY) || ent.getKey().equals(TableConstants.ROW_KEY)
                    || ent.getKey().equals(TableConstants.TIMESTAMP) || ent.getKey().equals("Etag")) {
                continue;
            }

            EntityProperty currProp = ent.getValue();
            if (currProp.getEdmType().mustAnnotateType()) {
                final String edmTypeString = currProp.getEdmType().toString();

                // property type
                generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

                // property key and value
                generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
            }
            else if (currProp.getEdmType() == EdmType.DOUBLE && currProp.getIsNull() == false) {
                final String edmTypeString = currProp.getEdmType().toString();
                final Double value = currProp.getValueAsDouble();

                // property type, if needed
                if (value.equals(Double.POSITIVE_INFINITY) || value.equals(Double.NEGATIVE_INFINITY)
                        || value.equals(Double.NaN)) {
                    generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

                    // property key and value
                    generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
                }
                else {
                    writeJsonProperty(generator, ent);
                }

            }
            else {
                writeJsonProperty(generator, ent);
            }
        }

        // end object
        generator.writeEndObject();
    }
private static void writeJsonEntity(final JsonGenerator generator, final TableEntity entity,
            final boolean isTableEntry, final OperationContext opContext) throws StorageException, IOException {

        HashMap<String, EntityProperty> properties = entity.writeEntity(opContext);
        if (properties == null) {
            properties = new HashMap<String, EntityProperty>();
        }

        // start object
        generator.writeStartObject();

        if (!isTableEntry) {
            Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey());
            Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey());
            Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp());

            // PartitionKey
            generator.writeStringField(TableConstants.PARTITION_KEY, entity.getPartitionKey());

            // RowKey
            generator.writeStringField(TableConstants.ROW_KEY, entity.getRowKey());

            // Timestamp
            generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
        }

        for (final Entry<String, EntityProperty> ent : properties.entrySet()) {
            if (ent.getKey().equals(TableConstants.PARTITION_KEY) || ent.getKey().equals(TableConstants.ROW_KEY)
                    || ent.getKey().equals(TableConstants.TIMESTAMP) || ent.getKey().equals("Etag")) {
                continue;
            }

            EntityProperty currProp = ent.getValue();
            if (currProp.getEdmType().mustAnnotateType()) {
                final String edmTypeString = currProp.getEdmType().toString();

                // property type
                generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

                // property key and value
                generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
            }
            else if (currProp.getEdmType() == EdmType.DOUBLE && currProp.getIsNull() == false) {
                final String edmTypeString = currProp.getEdmType().toString();
                final Double value = currProp.getValueAsDouble();

                // property type, if needed
                if (value.equals(Double.POSITIVE_INFINITY) || value.equals(Double.NEGATIVE_INFINITY)
                        || value.equals(Double.NaN)) {
                    generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString);

                    // property key and value
                    generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString());
                }
                else {
                    writeJsonProperty(generator, ent);
                }

            }
            else {
                writeJsonProperty(generator, ent);
            }
        }

        // end object
        generator.writeEndObject();
    }
private static void writeJsonEntity ( final JsonGenerator generator , final TableEntity entity , final boolean isTableEntry , final OperationContext opContext ) throws StorageException , IOException { HashMap < String , EntityProperty > properties = entity . writeEntity ( opContext ) ; if ( properties == null ) { properties = new HashMap < String , EntityProperty > ( ) ; } // start object generator . writeStartObject ( ) ; if ( ! isTableEntry ) { Utility . assertNotNull ( TableConstants . PARTITION_KEY , entity . getPartitionKey ( ) ) ; Utility . assertNotNull ( TableConstants . ROW_KEY , entity . getRowKey ( ) ) ; Utility . assertNotNull ( TableConstants . TIMESTAMP , entity . getTimestamp ( ) ) ; // PartitionKey generator . writeStringField ( TableConstants . PARTITION_KEY , entity . getPartitionKey ( ) ) ; // RowKey generator . writeStringField ( TableConstants . ROW_KEY , entity . getRowKey ( ) ) ; // Timestamp generator . writeStringField ( TableConstants . TIMESTAMP , Utility . getJavaISO8601Time ( entity . getTimestamp ( ) ) ) ; } for ( final Entry < String , EntityProperty > ent : properties . entrySet ( ) ) { if ( ent . getKey ( ) . equals ( TableConstants . PARTITION_KEY ) || ent . getKey ( ) . equals ( TableConstants . ROW_KEY ) || ent . getKey ( ) . equals ( TableConstants . TIMESTAMP ) || ent . getKey ( ) . equals ( "Etag" ) ) { continue ; } EntityProperty currProp = ent . getValue ( ) ; if ( currProp . getEdmType ( ) . mustAnnotateType ( ) ) { final String edmTypeString = currProp . getEdmType ( ) . toString ( ) ; // property type generator . writeStringField ( ent . getKey ( ) + ODataConstants . ODATA_TYPE_SUFFIX , edmTypeString ) ; // property key and value generator . writeStringField ( ent . getKey ( ) , ent . getValue ( ) . getValueAsString ( ) ) ; } else if ( currProp . getEdmType ( ) == EdmType . DOUBLE && currProp . getIsNull ( ) == false ) { final String edmTypeString = currProp . getEdmType ( ) . toString ( ) ; final Double value = currProp . getValueAsDouble ( ) ; // property type, if needed if ( value . equals ( Double . POSITIVE_INFINITY ) || value . equals ( Double . NEGATIVE_INFINITY ) || value . equals ( Double . NaN ) ) { generator . writeStringField ( ent . getKey ( ) + ODataConstants . ODATA_TYPE_SUFFIX , edmTypeString ) ; // property key and value generator . writeStringField ( ent . getKey ( ) , ent . getValue ( ) . getValueAsString ( ) ) ; } else { writeJsonProperty ( generator , ent ) ; } } else { writeJsonProperty ( generator , ent ) ; } } // end object generator . writeEndObject ( ) ; }
Reserved for internal use. Writes an entity to the specified <code>JsonGenerator</code> as an JSON resource

@param generator
The <code>JsonGenerator</code> to write the entity to.
@param entity
The instance implementing {@link TableEntity} to write to the output stream.
@param isTableEntry
A flag indicating the entity is a reference to a table at the top level of the storage service when
<code>true<code> and a reference to an entity within a table when <code>false</code>.
@param opContext
An {@link OperationContext} object used to track the execution of the operation.

@throws StorageException
if a Storage service error occurs.
@throws IOException
if an error occurs while accessing the stream.
Reserved for internal use . Writes an entity to the specified <code > JsonGenerator< / code > as an JSON resource