JSON string truncated to 240 characters

rsaritzky
Member Posts: 469
Hi everyone. I'm using the Newtonsoft JSON library in NAV2016 C/AL to format a JSON web request. The code is straightfoward:
The function "CreateJSONAttribute" is simple:
{ "name": "Shawn Ippotle", "company": "Shippo", "street1": "215 Clayton St.", "street2": "", "city": "San Francisco", "state": "CA", "zip": "94117", "country": "US", "phone": "+1 555 341 9393", "email": "shippotle@goship
This is about 240 characters long (if I delete the CRLF characters, it's 230).
If I create a shorter string by ending the code before the "email" token), it terminates the JSON string correctly:
{ "name": "Shawn Ippotle", "company": "Shippo", "street1": "215 Clayton St.", "street2": "", "city": "San Francisco", "state": "CA", "zip": "94117", "country": "US", "phone": "+1 555 341 9393" }
I've tried several other techniques, like using the JSONMgt codeunit and building the JSON string directly, with the same truncated result.
Has anyone encountered this? Any solutions?
Thanks
JsonTokenWriter := JsonTokenWriter.JTokenWriter; JsonTokenWriter.WriteStartObject; //curly open { CreateJSONAttribute('name','Shawn Ippotle'); CreateJSONAttribute('company','Shippo'); CreateJSONAttribute('street1','215 Clayton St.'); CreateJSONAttribute('street2',''); CreateJSONAttribute('city','San Francisco'); CreateJSONAttribute('state','CA'); CreateJSONAttribute('zip','94117'); CreateJSONAttribute('country','US'); CreateJSONAttribute('phone','+1 555 341 9393'); CreateJSONAttribute('email','shippotle@goshippo.com'); CreateJSONAttribute('is_residential','True'); CreateJSONAttribute('metadata','Customer ID 123456'); JSONTokenWriter.WriteEndObject; JsonObject := JsonTokenWriter.Token;
The function "CreateJSONAttribute" is simple:
LOCAL CreateJSONAttribute(AttributeName : Text;Value : Variant) JSONTokenWriter.WritePropertyName(AttributeName); JSONTokenWriter.WriteValue(FORMAT(Value));The resulting JSON object is truncated in the middle of one of the fields (the "email" field above):
{ "name": "Shawn Ippotle", "company": "Shippo", "street1": "215 Clayton St.", "street2": "", "city": "San Francisco", "state": "CA", "zip": "94117", "country": "US", "phone": "+1 555 341 9393", "email": "shippotle@goship
This is about 240 characters long (if I delete the CRLF characters, it's 230).
If I create a shorter string by ending the code before the "email" token), it terminates the JSON string correctly:
{ "name": "Shawn Ippotle", "company": "Shippo", "street1": "215 Clayton St.", "street2": "", "city": "San Francisco", "state": "CA", "zip": "94117", "country": "US", "phone": "+1 555 341 9393" }
I've tried several other techniques, like using the JSONMgt codeunit and building the JSON string directly, with the same truncated result.
Has anyone encountered this? Any solutions?
Thanks
Ron
0
Answers
-
I have resolved this issue. It turns out in NAV2016, even if a Text Variable is defined as more than 250 characters, it will only "accept" 250-ish characters from a Json token.
I dumped the JSON contents into a BigText variable instead, and all is good
Ron0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions