JSON.CreateNumber
-----------------

Creates a new JSON encoded number.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [2.7](newinversion27.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.CreateNumber"; Value ) 

**MBS**( **"JSON.CreateNumber";** /\* Creates a new JSON encoded number. \*/  
**$Value**) /\* The number value.e.g. 123.4 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Value | The number value. | 123.4 |

### Result

Returns JSON code.

### Description

Creates a new JSON encoded number.  
Version 10.0 or newer preserve formatting if you pass a text with a number containing digits with optionally one dot and one minus.  
Returns NULL if you pass empty text.  
### Examples

Creates a number:

 MBS ( "JSON.CreateNumber"; 123 )  
<small>  
Example result: 123</small>Create big number:

 MBS ( "JSON.CreateNumber"; 12063660878882855000013426248015578834577 )  
Pass through vs. number parsing:

 MBS ( "JSON.CreateNumber"; "123.5 " ) &amp; ¶ &amp; MBS ( "JSON.CreateNumber"; 123,5 )  
// in German with comma as separator second one is parsed as double precision value.  
<small>  
Example result:   
123.5  
123.500000</small>### See also

- [JSON.AddItemToArray](JSONAddItemToArray.md)
- [JSON.AddNumberToArray](JSONAddNumberToArray.md)
- [JSON.AddValueToArray](JSONAddValueToArray.md)
- [JSON.AddValueToObject](JSONAddValueToObject.md)
- [JSON.CreateNull](JSONCreateNull.md)

### Release notes

- **Version 12.0**
    - Fixed [JSON](https://www.mbsplugins.eu/component_JSON.shtml) functions to return NULL for numbers with no content, e.g. empty text. This affects [JSON.CreateNumber](https://www.mbsplugins.eu/JSONCreateNumber.shtml), [Dictionary.ToJSON](https://www.mbsplugins.eu/DictionaryToJSON.shtml), [FM.SQL.JSONColumn](https://www.mbsplugins.eu/FMSQLJSONColumn.shtml), [FM.SQL.JSONRecord](https://www.mbsplugins.eu/FMSQLJSONRecord.shtml) and [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml) functions.
- **Version 10.0**
    - Changed [JSON](https://www.mbsplugins.eu/component_JSON.shtml) functions to pass through floating numbers as is without rounding, in [JSON.CreateNumber](https://www.mbsplugins.eu/JSONCreateNumber.shtml), [JSON.AddNumberToArray](https://www.mbsplugins.eu/JSONAddNumberToArray.shtml) and others.
- **Version 8.0**
    - Fixed [JSON.CreateNumber](http://www.mbsplugins.eu/JSONCreateNumber.shtml) to return 0 for empty string.

### Example Databases

- [JavaScript/CoordinatDistance](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JavaScript/CoordinatDistance.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 11.6pr3](https://www.mbsplugins.de/archive/2021-12-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [FileMaker and JavaScript - the perfect combination](https://www.mbsplugins.de/archive/2020-02-03/FileMaker_and_JavaScript_-_the/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.6pr1](https://www.mbsplugins.de/archive/2019-12-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.6pr1](https://www.mbsplugins.de/archive/2017-12-06/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2020, Seite 17](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function is free to use.

Created 18th August 2014 , last changed 7th December 2021

  
[JSON.CreateNull](JSONCreateNull.md) - [JSON.CreateObject](JSONCreateObject.md)

[HTML Version](JSONCreateNumber.shtml)