# Partial data formatted using sprintf

**URL:** <https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731>\
**Category:** Legato Application Framework\
**Created:** [October 4, 2018, 6:55am UTC](https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731 "2018-10-04T06:55:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amruta](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@amruta](https://forum.legato.io/u/amruta)\
**Post date:** [October 4, 2018, 6:55am UTC](https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731/1 "2018-10-04T06:55:34Z")

</div>

Hi,  
I need to send json data to Airvantage via mqtt. I am using sprintf to format data in json string.  
Problem : Unable to get complete json string using sprintf though enough buffer allocated. In LE\_INFO , I am able to see only partial string. Please let me know the solution.

Code snippet : (sprintf code is continuous in one line)

char \*json\_str=(char \*)malloc(2048);  
memset(json\_str,0,2048);

sprintf(json\_str,“{ "flowmeter.RId": "1","flowmeter.Record\_Written\_Time": "10/01/2018 11:21:32","flowmeter.Flow\_Rate": "404443901281042","flowmeter.Totalize": "-57","flowmeter.DIStatus": "17","flowmeter.DITimeStamp":"13/06/2018 13:06:12" }”);

Output :

{ “flowmeter.RId”: “1”,“flowmeter.Record\_Written\_Time”: “10/01/2018 11:21:32”,“flowmeter.Flow\_Rate”: “404443901281042”,"flow

Request you to reply ASAP.  
LE\_INFO(“json\_str”);

---

<div class="post-metadata">

**Author:** ![ktanikel](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@ktanikel](https://forum.legato.io/u/ktanikel)\
**Post date:** [October 8, 2018, 10:07pm UTC](https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731/2 "2018-10-08T22:07:29Z")

</div>

I’ve seen LE\_INFO truncate lines that are too long, so it may have a character limit per line. You should probably verify the contents of your string through some other means, like writing directly to stdout or a file.

---

<div class="post-metadata">

**Author:** ![Manukumar](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@Manukumar](https://forum.legato.io/u/Manukumar)\
**Post date:** [October 9, 2018, 11:54am UTC](https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731/3 "2018-10-09T11:54:33Z")

</div>

We observed the same with LE\_INFO and we observed it has maximum size limit is 100 to 126 bytes.  
If we try to print more than maximum size LE\_INFO truncate the contents of strings.  
We tried the same with “printf(“output json %s\n”,json\_str);” It can able to display all the strings which used in sprintf.  
below is the steps,  
sprintf(json\_str,“{ “flowmeter.RId”: “1”,“flowmeter.Record\_Written\_Time”: “10/01/2018 11:21:32”,“flowmeter.Flow\_Rate”: “404443901281042”,“flowmeter.Totalize”: “-57”,“flowmeter.DIStatus”: “17”,“flowmeter.DITimeStamp”:“13/06/2018 13:06:12” }”);  
printf(“output json %s\n”,json\_str);

We can suggest to use printf insted of LE\_INFO(json\_str).

---

<div class="post-metadata">

**Author:** ![amruta](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@amruta](https://forum.legato.io/u/amruta)\
**Post date:** [October 11, 2018, 9:07am UTC](https://forum.legato.io/t/partial-data-formatted-using-sprintf/3731/4 "2018-10-11T09:07:24Z")

</div>

Thanks for your suggestions.
